Keep remote metadata when purge cannot remove a snapshot locally (closes #337)
check / check (push) Waiting to run
check / check (push) Waiting to run
snapshot purge, and the purge step of snapshot create --prune, logged a failure to delete a snapshot from the local index, deleted that snapshot's metadata from the destination store anyway, and exited 0. The purge now stops at that snapshot with an error before touching its remote metadata, so the command exits non-zero. Stopping matches what the same loop already does when the remote delete fails; snapshots purged before the failure stay purged. The test drives snapshot purge only: the trigger that makes the local index refuse the delete also breaks the backup's metadata export, so snapshot create --prune cannot be tested that way. Model: opus-5-5
This commit was merged in pull request #371.
This commit is contained in:
@@ -669,10 +669,11 @@ func (v *Vaultik) confirmAndExecutePurge(
|
||||
snapshotID := snap.ID.String()
|
||||
log.Info("Deleting snapshot", "id", snapshotID)
|
||||
|
||||
// Stop before the remote delete, so a snapshot still in the local
|
||||
// index keeps its metadata on the destination store.
|
||||
err := v.deleteSnapshotFromLocalDB(snapshotID)
|
||||
if err != nil {
|
||||
log.Error("Failed to delete from local database",
|
||||
"snapshot_id", snapshotID, "error", err)
|
||||
return fmt.Errorf("deleting snapshot %s from local index: %w", snapshotID, err)
|
||||
}
|
||||
|
||||
_, err = v.deleteRemoteSnapshotByKey(snapshot.RemoteSnapshotKey(snapshotID))
|
||||
|
||||
Reference in New Issue
Block a user