mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
xl: Create a delete-marker when no other version exists (#11362)
Currently, it is not possible to create a delete-marker when xl.meta does not exist (no version is created for that object yet). This makes a problem for replication and mc mirroring with versioning enabled. This also follows S3 specification.
This commit is contained in:
parent
f737a027cf
commit
6ef678663e
@ -886,7 +886,8 @@ func (s *xlStorage) DeleteVersions(ctx context.Context, volume string, versions
|
||||
return errs
|
||||
}
|
||||
|
||||
// DeleteVersion - deletes FileInfo metadata for path at `xl.meta`
|
||||
// DeleteVersion - deletes FileInfo metadata for path at `xl.meta`. Create a fresh
|
||||
// `xl.meta` if it does not exist and we creating a new delete-marker.
|
||||
func (s *xlStorage) DeleteVersion(ctx context.Context, volume, path string, fi FileInfo) error {
|
||||
if HasSuffix(path, SlashSeparator) {
|
||||
return s.Delete(ctx, volume, path, false)
|
||||
@ -894,10 +895,17 @@ func (s *xlStorage) DeleteVersion(ctx context.Context, volume, path string, fi F
|
||||
|
||||
buf, err := s.ReadAll(ctx, volume, pathJoin(path, xlStorageFormatFile))
|
||||
if err != nil {
|
||||
if err == errFileNotFound && fi.VersionID != "" {
|
||||
err = errFileVersionNotFound
|
||||
if err != errFileNotFound {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
if fi.Deleted {
|
||||
// Create a new xl.meta with a delete marker in it
|
||||
return s.WriteMetadata(ctx, volume, path, fi)
|
||||
}
|
||||
if fi.VersionID != "" {
|
||||
return errFileVersionNotFound
|
||||
}
|
||||
return errFileNotFound
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user