Skip to content

Commit

Permalink
Added scan interval to config
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Feb 18, 2024
1 parent 9e2eb5f commit f011049
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backend/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum LogLevel {
#[derive(Serialize, Deserialize)]
pub struct Config {
pub port: u16,
pub scan_interval: u64,
pub store_file: PathBuf,
pub log_file: PathBuf,
#[serde(with = "LogLevel")]
Expand All @@ -43,6 +44,7 @@ impl Config {
pub fn new() -> Self {
Config {
port: 12412,
scan_interval: 5000,
log_file: "microsdeck.log".into(),
store_file: "store".into(),
log_level: Level::INFO,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl Store {
}

pub fn remove_element(&self, id: &str) -> Result<(), Error> {
// these two operations have to happen within a single scope otherwise the try_write_to_file causes a deadlock
// these two operations have to happen within a single lock otherwise the try_write_to_file causes a deadlock
{
let mut lock = self.data.write().unwrap();
lock.remove_item(id)?;
Expand Down
3 changes: 2 additions & 1 deletion backend/src/watch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::cfg::CONFIG;
use crate::{ds::Store, dto::*, err::Error, sdcard::*, steam::*};
use std::borrow::Borrow;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -93,7 +94,7 @@ fn read_msd_directory(datastore: &Store, mount: &Option<String>) -> Result<(), E
}

pub async fn start_watch(datastore: Arc<Store>, sender: Sender<CardEvent>) -> Result<(), Error> {
let mut interval = interval(Duration::from_secs(1));
let mut interval = interval(Duration::from_millis(CONFIG.scan_interval));

let mut card_inserted = false;

Expand Down

0 comments on commit f011049

Please sign in to comment.