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.
master
Anis Elleuch 4 years ago committed by GitHub
parent f737a027cf
commit 6ef678663e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      cmd/xl-storage.go

@ -886,7 +886,8 @@ func (s *xlStorage) DeleteVersions(ctx context.Context, volume string, versions
return errs 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 { func (s *xlStorage) DeleteVersion(ctx context.Context, volume, path string, fi FileInfo) error {
if HasSuffix(path, SlashSeparator) { if HasSuffix(path, SlashSeparator) {
return s.Delete(ctx, volume, path, false) 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)) buf, err := s.ReadAll(ctx, volume, pathJoin(path, xlStorageFormatFile))
if err != nil { if err != nil {
if err == errFileNotFound && fi.VersionID != "" { if err != errFileNotFound {
err = errFileVersionNotFound 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 { if len(buf) == 0 {

Loading…
Cancel
Save