mirror of
https://github.com/minio/minio.git
synced 2025-04-16 00:49:09 -04: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
|
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,11 +895,18 @@ 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 {
|
||||||
if fi.VersionID != "" {
|
if fi.VersionID != "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user