upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-24 09:19:02 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-24 09:19:02 +0000
commit0b9861e14f23cc615d33ebd8845a36b40516a8a5 (patch)
tree6fd0f76eec50192aa4d8101852674a2ab56b5bcc /src
parentf62846b2966e0a3ffc93e718bbe44137d01c66b3 (diff)
Fix purgatory announcement not promoted when OIDs arrive via cross-owner state event copy
When git data is fetched into owner A's repo and a state event for owner B is released from purgatory (copying OIDs from A's repo to B's repo via process_state_with_git_data), owner B's purgatory announcement was never promoted. process_purgatory_announcements only promotes the announcement for the owner derived from source_repo_path (owner A), so owner B's announcement stayed in purgatory with its 30-minute expiry timer running. 30 minutes later the cleanup task would soft-expire owner B's entry, deleting the bare repository even though the announcement had been effectively satisfied. Fix: after a state event is successfully saved to the database, iterate over all announcements in db_repo_data and promote any purgatory announcement for owners whose repos received OIDs via the copy (i.e. repos other than source_repo_path).
Diffstat (limited to 'src')
-rw-r--r--src/git/sync.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/git/sync.rs b/src/git/sync.rs
index c24d16b..0d9a6b5 100644
--- a/src/git/sync.rs
+++ b/src/git/sync.rs
@@ -1076,6 +1076,57 @@ async fn process_purgatory_state_events(
1076 event_id = %entry.event.id, 1076 event_id = %entry.event.id,
1077 "Released state event from purgatory" 1077 "Released state event from purgatory"
1078 ); 1078 );
1079
1080 // Promote purgatory announcements for repos that received OIDs via
1081 // the state event copy above.
1082 //
1083 // process_state_with_git_data copies OIDs from source_repo_path to every
1084 // other owner repo listed in db_repo_data.announcements. When an
1085 // announcement for one of those owners is still in purgatory (e.g. the
1086 // meshman announcement waiting while c03rad0's state event triggered the
1087 // copy), the announcement would never be promoted because
1088 // process_purgatory_announcements only promotes the owner derived from
1089 // source_repo_path. Without this promotion the purgatory expiry timer
1090 // keeps running and eventually deletes the bare repo even though the
1091 // announcement was effectively satisfied.
1092 for announcement in &db_repo_data.announcements {
1093 let target_repo_path = git_data_path.join(announcement.repo_path());
1094 if target_repo_path == source_repo_path {
1095 // This is the source repo — already handled by
1096 // process_purgatory_announcements called before us.
1097 continue;
1098 }
1099 let owner = &announcement.event.pubkey;
1100 if let Some(ann_event) = purgatory.promote_announcement(owner, identifier) {
1101 match database.save_event(&ann_event).await {
1102 Ok(_) => {
1103 info!(
1104 identifier = %identifier,
1105 owner = %owner,
1106 event_id = %ann_event.id,
1107 "Promoted purgatory announcement for owner whose repo received OIDs via state event copy"
1108 );
1109 if let Some(relay) = local_relay {
1110 relay.notify_event(ann_event.clone());
1111 }
1112 result.announcements_released += 1;
1113 }
1114 Err(e) => {
1115 warn!(
1116 identifier = %identifier,
1117 owner = %owner,
1118 event_id = %ann_event.id,
1119 error = %e,
1120 "Failed to save promoted announcement to database"
1121 );
1122 result.errors.push(format!(
1123 "Failed to save promoted announcement for owner {}: {}",
1124 owner, e
1125 ));
1126 }
1127 }
1128 }
1129 }
1079 } 1130 }
1080 Err(e) => { 1131 Err(e) => {
1081 warn!( 1132 warn!(