From ee68ccadce6a6c90747cbdaae557babb4683413e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 26 Feb 2026 12:47:12 +0000 Subject: fix: rollback local state event cache on total push failure When all git servers reject or skip a push, delete the newly-published state event from the local nostr cache and restore the previous state event (if any), so that a subsequent retry starts from a clean baseline rather than a state that no server ever accepted. --- src/lib/client.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib') diff --git a/src/lib/client.rs b/src/lib/client.rs index c5c38cf..3f1f22e 100644 --- a/src/lib/client.rs +++ b/src/lib/client.rs @@ -2801,6 +2801,17 @@ fn describe_events(events: &[nostr::Event]) -> String { } } +pub async fn delete_event_from_local_cache( + git_repo_path: &Path, + event_id: nostr::EventId, +) -> Result<()> { + let db = get_local_cache_database(git_repo_path).await?; + db.delete(nostr::Filter::default().id(event_id)) + .await + .map_err(|e| anyhow!("failed to delete event from local cache: {e}"))?; + Ok(()) +} + fn remove_trailing_slash(s: &str) -> String { match s.strip_suffix('/') { Some(s) => s, -- cgit v1.2.3