Compare commits
1 Commits
ea8edd653f
...
6522ccea75
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6522ccea75 |
@@ -35,6 +35,7 @@ func (v *Vaultik) PruneBlobs(opts *PruneOptions) error {
|
|||||||
log.Info("Listing remote snapshots")
|
log.Info("Listing remote snapshots")
|
||||||
objectCh := v.Storage.ListStream(v.ctx, "metadata/")
|
objectCh := v.Storage.ListStream(v.ctx, "metadata/")
|
||||||
|
|
||||||
|
seen := make(map[string]bool)
|
||||||
var snapshotIDs []string
|
var snapshotIDs []string
|
||||||
for object := range objectCh {
|
for object := range objectCh {
|
||||||
if object.Err != nil {
|
if object.Err != nil {
|
||||||
@@ -47,15 +48,8 @@ func (v *Vaultik) PruneBlobs(opts *PruneOptions) error {
|
|||||||
// Check if this is a directory by looking for trailing slash
|
// Check if this is a directory by looking for trailing slash
|
||||||
if strings.HasSuffix(object.Key, "/") || strings.Contains(object.Key, "/manifest.json.zst") {
|
if strings.HasSuffix(object.Key, "/") || strings.Contains(object.Key, "/manifest.json.zst") {
|
||||||
snapshotID := parts[1]
|
snapshotID := parts[1]
|
||||||
// Only add unique snapshot IDs
|
if !seen[snapshotID] {
|
||||||
found := false
|
seen[snapshotID] = true
|
||||||
for _, id := range snapshotIDs {
|
|
||||||
if id == snapshotID {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
snapshotIDs = append(snapshotIDs, snapshotID)
|
snapshotIDs = append(snapshotIDs, snapshotID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -913,6 +913,7 @@ func (v *Vaultik) RemoveAllSnapshots(opts *RemoveOptions) (*RemoveResult, error)
|
|||||||
log.Info("Listing all snapshots")
|
log.Info("Listing all snapshots")
|
||||||
objectCh := v.Storage.ListStream(v.ctx, "metadata/")
|
objectCh := v.Storage.ListStream(v.ctx, "metadata/")
|
||||||
|
|
||||||
|
seen := make(map[string]bool)
|
||||||
var snapshotIDs []string
|
var snapshotIDs []string
|
||||||
for object := range objectCh {
|
for object := range objectCh {
|
||||||
if object.Err != nil {
|
if object.Err != nil {
|
||||||
@@ -927,14 +928,8 @@ func (v *Vaultik) RemoveAllSnapshots(opts *RemoveOptions) (*RemoveResult, error)
|
|||||||
}
|
}
|
||||||
if strings.HasSuffix(object.Key, "/") || strings.Contains(object.Key, "/manifest.json.zst") {
|
if strings.HasSuffix(object.Key, "/") || strings.Contains(object.Key, "/manifest.json.zst") {
|
||||||
sid := parts[1]
|
sid := parts[1]
|
||||||
found := false
|
if !seen[sid] {
|
||||||
for _, id := range snapshotIDs {
|
seen[sid] = true
|
||||||
if id == sid {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
snapshotIDs = append(snapshotIDs, sid)
|
snapshotIDs = append(snapshotIDs, sid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user