Integrate event restoration and cleanup into recovery flow

This commit is contained in:
DanConwayDev
2026-01-14 15:11:16 +00:00
parent 5b6cc95a19
commit 6e680c5649
+72 -1
View File
@@ -152,7 +152,78 @@ impl Nip34WritePolicy {
announcement.owner_npub(),
announcement.identifier
);
// Note: Event restoration will be handled in Phase 4B
// Restore events from holding database
let event_ids: Vec<_> =
recovery_info.events.iter().map(|e| e.id).collect();
match holding_db
.restore_events_to_main(
&self.ctx.database,
&event_ids,
)
.await
{
Ok(result) => {
tracing::info!(
"Restored {} events from holding database for {}/{}",
result.restored_count,
announcement.owner_npub(),
announcement.identifier
);
if result.failed_count > 0 {
tracing::warn!(
"Failed to restore {} events for {}/{}",
result.failed_count,
announcement.owner_npub(),
announcement.identifier
);
}
// Cleanup archive files after successful recovery
match crate::git::archive::cleanup_after_recovery(
&recovery_info.archive_path,
&announcement.owner_npub(),
&announcement.identifier,
) {
Ok(stats) => {
tracing::info!(
"Cleaned up archive for {}/{}: {} bytes reclaimed",
announcement.owner_npub(),
announcement.identifier,
stats.bytes_reclaimed
);
}
Err(e) => {
tracing::warn!(
"Failed to cleanup archive for {}/{}: {}",
announcement.owner_npub(),
announcement.identifier,
e
);
}
}
// Delete events from holding database
let deleted_count =
holding_db.delete_events(&event_ids).await;
tracing::info!(
"Deleted {} events from holding database for {}/{}",
deleted_count,
announcement.owner_npub(),
announcement.identifier
);
}
Err(e) => {
tracing::warn!(
"Failed to restore events for {}/{}: {}",
announcement.owner_npub(),
announcement.identifier,
e
);
}
}
}
Err(e) => {
tracing::warn!(