mirror of
https://github.com/minio/minio.git
synced 2025-04-10 06:30:07 -04:00
fix: rename legacy xl.json to xl.meta properly in ListDir() (#9863)
This commit is contained in:
parent
e79874f58e
commit
94424e14d7
@ -742,11 +742,11 @@ func (s *xlStorage) ListDirSplunk(volume, dirPath string, count int) (entries []
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dirPath = pathJoin(volumeDir, dirPath)
|
dirPathAbs := pathJoin(volumeDir, dirPath)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
entries, err = readDirN(dirPath, count)
|
entries, err = readDirN(dirPathAbs, count)
|
||||||
} else {
|
} else {
|
||||||
entries, err = readDir(dirPath)
|
entries, err = readDir(dirPathAbs)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -756,13 +756,13 @@ func (s *xlStorage) ListDirSplunk(volume, dirPath string, count int) (entries []
|
|||||||
if entry != receiptJSON {
|
if entry != receiptJSON {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, err = os.Stat(pathJoin(dirPath, entry, xlStorageFormatFile))
|
_, err = os.Stat(pathJoin(dirPathAbs, entry, xlStorageFormatFile))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
if err = s.renameLegacyMetadata(volume, entry); err == nil {
|
if err = s.renameLegacyMetadata(volume, pathJoin(dirPath, entry)); err == nil {
|
||||||
// Rename was successful means we found old `xl.json`
|
// Rename was successful means we found old `xl.json`
|
||||||
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
||||||
}
|
}
|
||||||
@ -1033,27 +1033,26 @@ func (s *xlStorage) ListDir(volume, dirPath string, count int) (entries []string
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dirPath = pathJoin(volumeDir, dirPath)
|
dirPathAbs := pathJoin(volumeDir, dirPath)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
entries, err = readDirN(dirPath, count)
|
entries, err = readDirN(dirPathAbs, count)
|
||||||
} else {
|
} else {
|
||||||
entries, err = readDir(dirPath)
|
entries, err = readDir(dirPathAbs)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, entry := range entries {
|
for i, entry := range entries {
|
||||||
_, err = os.Stat(pathJoin(dirPath, entry, xlStorageFormatFile))
|
_, err = os.Stat(pathJoin(dirPathAbs, entry, xlStorageFormatFile))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
if err = s.renameLegacyMetadata(volume, entry); err == nil {
|
if err = s.renameLegacyMetadata(volume, pathJoin(dirPath, entry)); err == nil {
|
||||||
// if rename was successful, means we did find old `xl.json`
|
// if rename was successful, means we did find old `xl.json`
|
||||||
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
entries[i] = strings.TrimSuffix(entry, SlashSeparator)
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user