upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 12:47:12 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 15:26:18 +0000
commitee68ccadce6a6c90747cbdaae557babb4683413e (patch)
treec3be43110d6f9d0f82fb56c9b839644e51b4788f /src/lib
parentf252dd0f1fb7374b5b6d44e77facdc902ee52c43 (diff)
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.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/client.rs11
1 files changed, 11 insertions, 0 deletions
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 {
2801 } 2801 }
2802} 2802}
2803 2803
2804pub async fn delete_event_from_local_cache(
2805 git_repo_path: &Path,
2806 event_id: nostr::EventId,
2807) -> Result<()> {
2808 let db = get_local_cache_database(git_repo_path).await?;
2809 db.delete(nostr::Filter::default().id(event_id))
2810 .await
2811 .map_err(|e| anyhow!("failed to delete event from local cache: {e}"))?;
2812 Ok(())
2813}
2814
2804fn remove_trailing_slash(s: &str) -> String { 2815fn remove_trailing_slash(s: &str) -> String {
2805 match s.strip_suffix('/') { 2816 match s.strip_suffix('/') {
2806 Some(s) => s, 2817 Some(s) => s,