Compare commits
1 Commits
4bcca47ce6
...
fix/sync-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
332ea26bce |
@@ -361,6 +361,33 @@ func (v *Vaultik) ListSnapshots(jsonOutput bool) error {
|
|||||||
localSnapshotMap[s.ID.String()] = s
|
localSnapshotMap[s.ID.String()] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove local snapshots that don't exist remotely
|
||||||
|
for _, snapshot := range localSnapshots {
|
||||||
|
snapshotIDStr := snapshot.ID.String()
|
||||||
|
if !remoteSnapshots[snapshotIDStr] {
|
||||||
|
log.Info("Removing local snapshot not found in remote", "snapshot_id", snapshot.ID)
|
||||||
|
|
||||||
|
// Delete related records first to avoid foreign key constraints
|
||||||
|
if err := v.Repositories.Snapshots.DeleteSnapshotFiles(v.ctx, snapshotIDStr); err != nil {
|
||||||
|
log.Error("Failed to delete snapshot files", "snapshot_id", snapshot.ID, "error", err)
|
||||||
|
}
|
||||||
|
if err := v.Repositories.Snapshots.DeleteSnapshotBlobs(v.ctx, snapshotIDStr); err != nil {
|
||||||
|
log.Error("Failed to delete snapshot blobs", "snapshot_id", snapshot.ID, "error", err)
|
||||||
|
}
|
||||||
|
if err := v.Repositories.Snapshots.DeleteSnapshotUploads(v.ctx, snapshotIDStr); err != nil {
|
||||||
|
log.Error("Failed to delete snapshot uploads", "snapshot_id", snapshot.ID, "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now delete the snapshot itself
|
||||||
|
if err := v.Repositories.Snapshots.Delete(v.ctx, snapshotIDStr); err != nil {
|
||||||
|
log.Error("Failed to delete local snapshot", "snapshot_id", snapshot.ID, "error", err)
|
||||||
|
} else {
|
||||||
|
log.Info("Deleted local snapshot not found in remote", "snapshot_id", snapshot.ID)
|
||||||
|
delete(localSnapshotMap, snapshotIDStr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build final snapshot list
|
// Build final snapshot list
|
||||||
snapshots := make([]SnapshotInfo, 0, len(remoteSnapshots))
|
snapshots := make([]SnapshotInfo, 0, len(remoteSnapshots))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user