From 7b1b36b8c7e448d1d170c8c6e1f88bb766163fbb Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 26 May 2026 20:38:49 +0530 Subject: Fix push_target remote reuse and non-fatal per-repo errors - git_mirror: reuse existing push_target remote via remote_set_url instead of failing on 'remote already exists' on subsequent cycles - mirror_cycle: catch per-repo errors instead of propagating with ? so one failed clone doesn't abort the remaining 87 repos - Add PLAN.md with bug tracking checklist --- src/git_mirror.rs | 13 ++++++++++++- src/main.rs | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/git_mirror.rs b/src/git_mirror.rs index 47c0442..6866de3 100644 --- a/src/git_mirror.rs +++ b/src/git_mirror.rs @@ -134,7 +134,18 @@ impl GitMirror { let repo = git2::Repository::open(repo_path) .with_context(|| format!("failed to open bare repo at {:?}", repo_path))?; - let mut remote = repo.remote("push_target", target_url)?; + let remote_name = "push_target"; + + match repo.find_remote(remote_name) { + Ok(_) => { + repo.remote_set_url(remote_name, target_url)?; + } + Err(_) => { + repo.remote(remote_name, target_url)?; + } + } + + let mut remote = repo.find_remote(remote_name)?; let mut callbacks = RemoteCallbacks::new(); callbacks.credentials(|_url, _username, _allowed| git2::Cred::default()); diff --git a/src/main.rs b/src/main.rs index 494342c..3fcd27b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,13 +190,21 @@ async fn mirror_cycle( "mirroring to missing servers" ); - mirror.mirror_repo_to_servers(db, repo, &missing).await?; - nostr_mirror.forward_repo_events(db, repo, servers).await?; + if let Err(e) = mirror.mirror_repo_to_servers(db, repo, &missing).await { + tracing::error!(identifier = %repo.identifier, error = %e, "git mirror failed for repo, continuing"); + } + + if let Err(e) = nostr_mirror.forward_repo_events(db, repo, servers).await { + tracing::error!(identifier = %repo.identifier, error = %e, "nostr mirror failed for repo, continuing"); + } } - nostr_mirror + if let Err(e) = nostr_mirror .sync_all_events(db, &config.npubs, servers) - .await?; + .await + { + tracing::error!(error = %e, "event sync failed"); + } tracing::info!("mirror cycle complete"); Ok(()) -- cgit v1.2.3