mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
heal legacy objects when versioning is enabled after upgrade (#13671)
legacy objects in 'xl.json' after upgrade, should have following sequence of events - bucket should have versioning enabled and the object should have been overwritten with another version of an object. this situation was not handled, which would lead to older objects to stay perpetually with "legacy" dataDir, however these objects were readable by all means - there weren't converted to newer format. This PR fixes this situation properly.
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/minio/minio/internal/logger"
|
||||
)
|
||||
|
||||
// versionsSorter sorts FileInfo slices by version.
|
||||
@@ -121,15 +123,17 @@ func getFileInfo(xlMetaBuf []byte, volume, path, versionID string, data bool) (F
|
||||
xlMeta := &xlMetaV1Object{}
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal(xlMetaBuf, xlMeta); err != nil {
|
||||
logger.LogIf(GlobalContext, fmt.Errorf("unable to unmarshal json object: %v", err))
|
||||
return FileInfo{}, errFileCorrupt
|
||||
}
|
||||
|
||||
fi, err := xlMeta.ToFileInfo(volume, path)
|
||||
if err == errFileNotFound && versionID != "" {
|
||||
return fi, errFileVersionNotFound
|
||||
if err != nil {
|
||||
return FileInfo{}, err
|
||||
}
|
||||
fi.IsLatest = true // No versions so current version is latest.
|
||||
|
||||
fi.XLV1 = true // indicates older version
|
||||
fi.IsLatest = true // No versions so current version is latest.
|
||||
return fi, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user