diff --git a/src/cache.rs b/src/cache.rs index 533e27a..99b56cc 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -23,6 +23,10 @@ impl CacheEntry { let now = chrono::Utc::now(); now > self.changed + ttl } + + pub fn uuid(&self) -> &String { + return &self.uuid; + } } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index 6f4ccc4..1d9d222 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,7 +93,12 @@ fn check_and_notify( match cache { Ok(mut cache) => { if let Some(entry) = cache.get(&mountpoint) { - if entry.expired(ttl) { + if entry.uuid() != uuid { + cache.update(&mountpoint, &uuid); + if let Err(e) = cache.save(&cache_path) { + eprintln!("Failed to save cache: {}", e); + } + } else if entry.expired(ttl) { notify(mountpoint, uuid, entry.changed(), mailto); } } else {