mirror of
https://github.com/minio/minio.git
synced 2025-05-21 17:43:48 -04:00
xl: Delete older data-dir when replacing an existing version-id (#16176)
This commit is contained in:
parent
932d2c3c62
commit
1bae32dc96
@ -2329,12 +2329,18 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
||||
}
|
||||
}
|
||||
|
||||
var oldDstDataPath string
|
||||
var oldDstDataPath, reqVID string
|
||||
|
||||
if fi.VersionID == "" {
|
||||
// return the latest "null" versionId info
|
||||
ofi, err := xlMeta.ToFileInfo(dstVolume, dstPath, nullVersionID)
|
||||
reqVID = nullVersionID
|
||||
} else {
|
||||
reqVID = fi.VersionID
|
||||
}
|
||||
|
||||
// Replace the data of null version or any other existing version-id
|
||||
ofi, err := xlMeta.ToFileInfo(dstVolume, dstPath, reqVID)
|
||||
if err == nil && !ofi.Deleted {
|
||||
if xlMeta.SharedDataDirCountStr(nullVersionID, ofi.DataDir) == 0 {
|
||||
if xlMeta.SharedDataDirCountStr(reqVID, ofi.DataDir) == 0 {
|
||||
// Purge the destination path as we are not preserving anything
|
||||
// versioned object was not requested.
|
||||
oldDstDataPath = pathJoin(dstVolumeDir, dstPath, ofi.DataDir)
|
||||
@ -2343,22 +2349,23 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
||||
// avoid setting oldDstDataPath at that point.
|
||||
if oldDstDataPath == dstDataPath {
|
||||
oldDstDataPath = ""
|
||||
}
|
||||
xlMeta.data.remove(nullVersionID, ofi.DataDir)
|
||||
} else {
|
||||
xlMeta.data.remove(reqVID, ofi.DataDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty fi.VersionID indicates that versioning is either
|
||||
// suspended or disabled on this bucket. RenameData will replace
|
||||
// the 'null' version. We add a free-version to track its tiered
|
||||
// content for asynchronous deletion.
|
||||
if !fi.IsRestoreObjReq() {
|
||||
if fi.VersionID == "" && !fi.IsRestoreObjReq() {
|
||||
// Note: Restore object request reuses PutObject/Multipart
|
||||
// upload to copy back its data from the remote tier. This
|
||||
// doesn't replace the existing version, so we don't need to add
|
||||
// a free-version.
|
||||
xlMeta.AddFreeVersion(fi)
|
||||
}
|
||||
}
|
||||
|
||||
// indicates if RenameData() is called by healing.
|
||||
// healing doesn't preserve the dataDir as 'legacy'
|
||||
|
Loading…
x
Reference in New Issue
Block a user