Skip identical entries when listing chunks

The prune command can remove redundant chunks (chunks with the same chunk id
but at different subdirectory level).  However, if the same chunk appears
mutliple times in the listing returned by the storage, it will be treated as
a redundant chunk and thus removed.
This commit is contained in:
Gilbert Chen
2023-09-27 15:31:08 -04:00
parent 4e9d2c4cca
commit d92b1734f4

View File

@@ -2427,7 +2427,13 @@ func (manager *SnapshotManager) pruneSnapshotsExhaustive(referencedFossils map[s
} }
allFiles, _ := manager.ListAllFiles(manager.storage, chunkDir) allFiles, _ := manager.ListAllFiles(manager.storage, chunkDir)
uniqueFiles := make(map[string]bool)
for _, file := range allFiles { for _, file := range allFiles {
if _, found := uniqueFiles[file]; found {
continue
}
uniqueFiles[file] = true
if len(file) == 0 || file[len(file)-1] == '/' { if len(file) == 0 || file[len(file)-1] == '/' {
continue continue
} }