mirror of
https://github.com/minio/minio.git
synced 2025-03-27 16:00:57 -04:00
implement helpers to get relevant info instead of FileInfo() (#18228)
This commit is contained in:
parent
763ff085a6
commit
409c391850
@ -328,6 +328,18 @@ func (x xlMetaV2VersionHeader) sortsBefore(o xlMetaV2VersionHeader) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (j xlMetaV2Version) getDataDir() string {
|
||||
if j.Valid() {
|
||||
switch j.Type {
|
||||
case LegacyType:
|
||||
return j.ObjectV1.DataDir
|
||||
case ObjectType:
|
||||
return uuid.UUID(j.ObjectV2.DataDir).String()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Valid xl meta xlMetaV2Version is valid
|
||||
func (j xlMetaV2Version) Valid() bool {
|
||||
if !j.Type.valid() {
|
||||
@ -1170,6 +1182,20 @@ func (x *xlMetaV2) AppendTo(dst []byte) ([]byte, error) {
|
||||
return append(dst, x.data...), nil
|
||||
}
|
||||
|
||||
func (x *xlMetaV2) findVersionStr(key string) (idx int, ver *xlMetaV2Version, err error) {
|
||||
if key == nullVersionID {
|
||||
key = ""
|
||||
}
|
||||
var u uuid.UUID
|
||||
if key != "" {
|
||||
u, err = uuid.Parse(key)
|
||||
if err != nil {
|
||||
return -1, nil, errFileVersionNotFound
|
||||
}
|
||||
}
|
||||
return x.findVersion(u)
|
||||
}
|
||||
|
||||
func (x *xlMetaV2) findVersion(key [16]byte) (idx int, ver *xlMetaV2Version, err error) {
|
||||
for i, ver := range x.versions {
|
||||
if key == ver.header.VersionID {
|
||||
|
@ -2442,19 +2442,20 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
||||
}
|
||||
|
||||
// Replace the data of null version or any other existing version-id
|
||||
ofi, err := xlMeta.ToFileInfo(dstVolume, dstPath, reqVID, false, false)
|
||||
if err == nil && !ofi.Deleted {
|
||||
if xlMeta.SharedDataDirCountStr(reqVID, ofi.DataDir) == 0 {
|
||||
_, ver, err := xlMeta.findVersionStr(reqVID)
|
||||
if err == nil {
|
||||
dataDir := ver.getDataDir()
|
||||
if dataDir != "" && (xlMeta.SharedDataDirCountStr(reqVID, dataDir) == 0) {
|
||||
// Purge the destination path as we are not preserving anything
|
||||
// versioned object was not requested.
|
||||
oldDstDataPath = pathJoin(dstVolumeDir, dstPath, ofi.DataDir)
|
||||
oldDstDataPath = pathJoin(dstVolumeDir, dstPath, dataDir)
|
||||
// if old destination path is same as new destination path
|
||||
// there is nothing to purge, this is true in case of healing
|
||||
// avoid setting oldDstDataPath at that point.
|
||||
if oldDstDataPath == dstDataPath {
|
||||
oldDstDataPath = ""
|
||||
} else {
|
||||
xlMeta.data.remove(reqVID, ofi.DataDir)
|
||||
xlMeta.data.remove(reqVID, dataDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user