Skip to content

Commit

Permalink
Rename the notification_ttl configuration
Browse files Browse the repository at this point in the history
Rename the notification_ttl configuration to min_command_exec_freq
which is more descriptive of what the configuration holds.

Signed-off-by: Jason Rogena <[email protected]>
  • Loading branch information
jasonrogena committed Jun 21, 2022
1 parent 85e4529 commit 35a8738
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Config {
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
pub struct FsWatch {
pub notification_ttl: Option<u64>,
pub min_command_exec_freq: Option<u64>,
}

#[derive(Debug, Deserialize)]
Expand Down
13 changes: 8 additions & 5 deletions src/fs_notify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ impl<'a> Notify<'a> {
None => return true,
};

let notification_ttl = match config.notification_ttl {
let min_command_exec_freq = match config.min_command_exec_freq {
Some(n) => n,
None => return true,
};

if notification_ttl == 0 {
if min_command_exec_freq == 0 {
return true;
}

Expand All @@ -95,13 +95,16 @@ impl<'a> Notify<'a> {
None => return,
};

let notification_ttl = match config.notification_ttl {
let min_command_exec_freq = match config.min_command_exec_freq {
Some(n) => n,
None => return,
};

self.notify_ttl
.insert(path.to_string(), (), Duration::from_secs(notification_ttl));
self.notify_ttl.insert(
path.to_string(),
(),
Duration::from_secs(min_command_exec_freq),
);
}

#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion src/fs_notify/tests_supported_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn test_notify_ttl() {
let (on_event_sender, on_event_receiver) = channel();
let (mut notify_obj, unwatch_sender) = Notify::new(
&Some(FsWatch {
notification_ttl: Some(60),
min_command_exec_freq: Some(60),
}),
&paths,
on_event_sender,
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/bad-missing-directories.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ echo "{file_path} is a show episode. The file's MIME type is {mime_type}"
mime_type_regexes = [ "video\\/.+" ]

[fs_watch]
notification_ttl = 10
min_command_exec_freq = 10
2 changes: 1 addition & 1 deletion tests/configs/good-windows.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ echo "{{ file_path }} is a book. The file's MIME type is {{ mime_type }}" > tes
directories = [ "tests\\files\\text" ]

[fs_watch]
notification_ttl = 60
min_command_exec_freq = 60
2 changes: 1 addition & 1 deletion tests/configs/good.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ echo "{{ file_path }} is a book. The file's MIME type is {{ mime_type }}" > tes
directories = [ "tests/files/text" ]

[fs_watch]
notification_ttl = 60
min_command_exec_freq = 60

0 comments on commit 35a8738

Please sign in to comment.