diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-20 18:10:14 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-20 18:10:14 +0100 |
commit | 47c461c41de13ec3428692b75a68cd18c1d89546 (patch) | |
tree | 31a0310ae0745c2cb19d5399d48d08222f8677b7 /src | |
parent | 65da33fc24cac06a8f9d2d56d89d6f993413186b (diff) |
Revert "run configure_wan regardless of event"
This reverts commit fa4aff43ba4f4caed5ce6d271d06c25017a18bc9.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 2830a78..e203ec9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,8 @@ use std::path::Path; use std::thread; use std::time::Duration; -use notify::{Event, RecursiveMode, Watcher}; +use notify::event::{CreateKind, ModifyKind}; +use notify::{Event, EventKind, RecursiveMode, Watcher}; use rsdsl_ip_config::IpConfig; fn main() -> Result<()> { @@ -23,7 +24,15 @@ fn main() -> Result<()> { configure_wan(); let mut watcher = notify::recommended_watcher(|res: notify::Result<Event>| match res { - Ok(_) => configure_wan(), + Ok(event) => match event.kind { + EventKind::Create(kind) if kind == CreateKind::File => { + configure_wan(); + } + EventKind::Modify(kind) if matches!(kind, ModifyKind::Data(_)) => { + configure_wan(); + } + _ => {} + }, Err(e) => println!("[netlinkd] watch error: {:?}", e), })?; |