mirror of
https://github.com/minio/minio.git
synced 2025-07-28 09:50:09 -04:00
avoid double deletes() when no more versions (#16206)
This commit is contained in:
parent
c233c8e329
commit
20ef5e7a6a
@ -1118,6 +1118,7 @@ func (s *xlStorage) DeleteVersion(ctx context.Context, volume, path string, fi F
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(xlMeta.versions) != 0 {
|
if len(xlMeta.versions) != 0 {
|
||||||
|
// xl.meta must still exist for other versions, dataDir is purged.
|
||||||
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
||||||
defer metaDataPoolPut(buf)
|
defer metaDataPoolPut(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1127,17 +1128,13 @@ func (s *xlStorage) DeleteVersion(ctx context.Context, volume, path string, fi F
|
|||||||
return s.WriteAll(ctx, volume, pathJoin(path, xlStorageFormatFile), buf)
|
return s.WriteAll(ctx, volume, pathJoin(path, xlStorageFormatFile), buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move xl.meta to trash
|
// No more versions, this is the last version purge everything.
|
||||||
filePath := pathJoin(volumeDir, path, xlStorageFormatFile)
|
filePath := pathJoin(volumeDir, path)
|
||||||
if err = checkPathLength(filePath); err != nil {
|
if err = checkPathLength(filePath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.moveToTrash(filePath, false, false)
|
return s.deleteFile(volumeDir, filePath, true, false)
|
||||||
if err == nil || err == errFileNotFound {
|
|
||||||
s.deleteFile(volumeDir, pathJoin(volumeDir, path), false, false)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates only metadata for a given version.
|
// Updates only metadata for a given version.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user