mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 23:18:24 +00:00
Integrate event restoration and cleanup into recovery flow
This commit is contained in:
+72
-1
@@ -152,7 +152,78 @@ impl Nip34WritePolicy {
|
|||||||
announcement.owner_npub(),
|
announcement.owner_npub(),
|
||||||
announcement.identifier
|
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) => {
|
Err(e) => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
|
|||||||
Reference in New Issue
Block a user