From 9ec713b8079f564f7a892f1affd2a780f805b669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 2 Sep 2024 15:32:59 -0700 Subject: [PATCH] Fix empty cache entry state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was an issue where an empty cache entry would get interpreted as a "no cache entry found" situation and cause notepush to always fetch a new mutelist Signed-off-by: Daniel D’Aquino --- src/notification_manager/nostr_event_cache.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/notification_manager/nostr_event_cache.rs b/src/notification_manager/nostr_event_cache.rs index b2b9840..7e6b309 100644 --- a/src/notification_manager/nostr_event_cache.rs +++ b/src/notification_manager/nostr_event_cache.rs @@ -97,8 +97,15 @@ impl Cache { if let Some(entry) = self.mute_lists.get(pubkey) { let entry = entry.clone(); // Clone the Arc to avoid borrowing issues if !entry.is_expired(self.max_age) { - if let Some(event) = entry.event.clone() { - return Ok(event.to_mute_list()); + match &entry.event { + Some(event) => { + log::debug!("Cached mute list for pubkey {} was found", pubkey.to_hex()); + return Ok(event.to_mute_list()); + } + None => { + log::debug!("Empty mute list cache entry for pubkey {}", pubkey.to_hex()); + return Ok(None); + } } } else { log::debug!("Mute list for pubkey {} is expired, removing it from the cache", pubkey.to_hex()); @@ -106,6 +113,7 @@ impl Cache { self.remove_event_from_all_maps(&entry.event); } } + log::debug!("Mute list for pubkey {} not found on cache", pubkey.to_hex()); Err(CacheError::NotFound) }