Save minio version information centrally (#15181)

This commit is contained in:
Anis Elleuch 2022-06-29 22:45:49 +01:00 committed by GitHub
parent 65b4b100a8
commit 54a061bdda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 7 deletions

View File

@ -326,7 +326,6 @@ func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string,
partsMetadata := make([]FileInfo, len(onlineDisks)) partsMetadata := make([]FileInfo, len(onlineDisks))
fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives)
fi.WrittenByVersion = globalVersionUnix
fi.VersionID = opts.VersionID fi.VersionID = opts.VersionID
if opts.Versioned && fi.VersionID == "" { if opts.Versioned && fi.VersionID == "" {
fi.VersionID = mustGetUUID() fi.VersionID = mustGetUUID()

View File

@ -944,7 +944,6 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
partsMetadata := make([]FileInfo, len(storageDisks)) partsMetadata := make([]FileInfo, len(storageDisks))
fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives)
fi.WrittenByVersion = globalVersionUnix
fi.VersionID = opts.VersionID fi.VersionID = opts.VersionID
if opts.Versioned && fi.VersionID == "" { if opts.Versioned && fi.VersionID == "" {
fi.VersionID = mustGetUUID() fi.VersionID = mustGetUUID()

View File

@ -941,7 +941,6 @@ func (es *erasureSingle) putObject(ctx context.Context, bucket string, object st
partsMetadata := make([]FileInfo, len(storageDisks)) partsMetadata := make([]FileInfo, len(storageDisks))
fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives)
fi.WrittenByVersion = globalVersionUnix
fi.VersionID = opts.VersionID fi.VersionID = opts.VersionID
if opts.Versioned && fi.VersionID == "" { if opts.Versioned && fi.VersionID == "" {
fi.VersionID = mustGetUUID() fi.VersionID = mustGetUUID()
@ -2071,7 +2070,6 @@ func (es *erasureSingle) newMultipartUpload(ctx context.Context, bucket string,
partsMetadata := make([]FileInfo, len(onlineDisks)) partsMetadata := make([]FileInfo, len(onlineDisks))
fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives)
fi.WrittenByVersion = globalVersionUnix
fi.VersionID = opts.VersionID fi.VersionID = opts.VersionID
if opts.Versioned && fi.VersionID == "" { if opts.Versioned && fi.VersionID == "" {
fi.VersionID = mustGetUUID() fi.VersionID = mustGetUUID()

View File

@ -1189,6 +1189,7 @@ func (x *xlMetaV2) DeleteVersion(fi FileInfo) (string, error) {
ModTime: fi.ModTime.UnixNano(), ModTime: fi.ModTime.UnixNano(),
MetaSys: make(map[string][]byte), MetaSys: make(map[string][]byte),
}, },
WrittenByVersion: globalVersionUnix,
} }
if !ventry.Valid() { if !ventry.Valid() {
return "", errors.New("internal error: invalid version entry generated") return "", errors.New("internal error: invalid version entry generated")
@ -1432,7 +1433,7 @@ func (x *xlMetaV2) AddVersion(fi FileInfo) error {
} }
ventry := xlMetaV2Version{ ventry := xlMetaV2Version{
WrittenByVersion: fi.WrittenByVersion, WrittenByVersion: globalVersionUnix,
} }
if fi.Deleted { if fi.Deleted {
@ -1598,7 +1599,7 @@ func (x *xlMetaV2) AddLegacy(m *xlMetaV1Object) error {
} }
m.VersionID = nullVersionID m.VersionID = nullVersionID
return x.addVersion(xlMetaV2Version{ObjectV1: m, Type: LegacyType}) return x.addVersion(xlMetaV2Version{ObjectV1: m, Type: LegacyType, WrittenByVersion: globalVersionUnix})
} }
// ToFileInfo converts xlMetaV2 into a common FileInfo datastructure // ToFileInfo converts xlMetaV2 into a common FileInfo datastructure

View File

@ -35,7 +35,7 @@ func (j xlMetaV2Object) InitFreeVersion(fi FileInfo) (xlMetaV2Version, bool) {
if err != nil { if err != nil {
panic(fmt.Errorf("Invalid Tier Object delete marker versionId %s %v", fi.TierFreeVersionID(), err)) panic(fmt.Errorf("Invalid Tier Object delete marker versionId %s %v", fi.TierFreeVersionID(), err))
} }
freeEntry := xlMetaV2Version{Type: DeleteType} freeEntry := xlMetaV2Version{Type: DeleteType, WrittenByVersion: globalVersionUnix}
freeEntry.DeleteMarker = &xlMetaV2DeleteMarker{ freeEntry.DeleteMarker = &xlMetaV2DeleteMarker{
VersionID: vID, VersionID: vID,
ModTime: j.ModTime, // fi.ModTime may be empty ModTime: j.ModTime, // fi.ModTime may be empty