Skip to content

Commit

Permalink
Merge pull request #846 from versity/fix/versioning-delete-object-del…
Browse files Browse the repository at this point in the history
…-marker-header

fix: Added DeleteMarker to the DeleteObject action response when atte…
  • Loading branch information
benmcclelland authored Sep 26, 2024
2 parents 9221a13 + 8574a4c commit 2b9111f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions backend/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,8 @@ func (p *Posix) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput) (
}

return &s3.DeleteObjectOutput{
VersionId: &versionId,
DeleteMarker: getBoolPtr(true),
VersionId: &versionId,
}, nil
} else {
versionPath := p.genObjVersionPath(bucket, object)
Expand Down Expand Up @@ -2401,11 +2402,10 @@ func (p *Posix) DeleteObjects(ctx context.Context, input *s3.DeleteObjectsInput)
delEntity := types.DeletedObject{
Key: obj.Key,
DeleteMarker: res.DeleteMarker,
VersionId: obj.VersionId,
}
if delEntity.DeleteMarker != nil && *delEntity.DeleteMarker {
delEntity.DeleteMarkerVersionId = res.VersionId
} else {
delEntity.VersionId = res.VersionId
}

delResult = append(delResult, delEntity)
Expand Down
27 changes: 18 additions & 9 deletions tests/integration/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -10950,6 +10950,9 @@ func Versioning_DeleteObject_delete_a_delete_marker(s *S3Conf) error {
return err
}

if out.DeleteMarker == nil || !*out.DeleteMarker {
return fmt.Errorf("expected the response DeleteMarker to be true")
}
if out.VersionId == nil || *out.VersionId == "" {
return fmt.Errorf("expected non empty versionId")
}
Expand Down Expand Up @@ -11019,14 +11022,17 @@ func Versioning_DeleteObjects_success(s *S3Conf) error {

delResult := []types.DeletedObject{
{
Key: obj1Version[0].Key,
VersionId: obj1Version[0].VersionId,
Key: obj1Version[0].Key,
VersionId: obj1Version[0].VersionId,
DeleteMarker: getBoolPtr(false),
},
{
Key: obj2Version[0].Key,
Key: obj2Version[0].Key,
DeleteMarker: getBoolPtr(true),
},
{
Key: obj3Version[0].Key,
Key: obj3Version[0].Key,
DeleteMarker: getBoolPtr(true),
},
}

Expand Down Expand Up @@ -11054,15 +11060,14 @@ func Versioning_DeleteObjects_success(s *S3Conf) error {
{
IsLatest: getBoolPtr(true),
Key: out.Deleted[1].Key,
VersionId: out.Deleted[1].VersionId,
VersionId: out.Deleted[1].DeleteMarkerVersionId,
},
{
IsLatest: getBoolPtr(true),
Key: out.Deleted[2].Key,
VersionId: out.Deleted[2].VersionId,
VersionId: out.Deleted[2].DeleteMarkerVersionId,
},
}

if !compareVersions(versions, res.Versions) {
return fmt.Errorf("expected the resulting versions to be %v, instead got %v", versions, res.Versions)
}
Expand Down Expand Up @@ -11109,10 +11114,12 @@ func Versioning_DeleteObjects_delete_deleteMarkers(s *S3Conf) error {

delResult := []types.DeletedObject{
{
Key: obj1Version[0].Key,
Key: obj1Version[0].Key,
DeleteMarker: getBoolPtr(true),
},
{
Key: obj2Version[0].Key,
Key: obj2Version[0].Key,
DeleteMarker: getBoolPtr(true),
},
}

Expand Down Expand Up @@ -11152,11 +11159,13 @@ func Versioning_DeleteObjects_delete_deleteMarkers(s *S3Conf) error {
Key: out.Deleted[0].Key,
DeleteMarker: getBoolPtr(true),
DeleteMarkerVersionId: out.Deleted[0].VersionId,
VersionId: out.Deleted[0].VersionId,
},
{
Key: out.Deleted[1].Key,
DeleteMarker: getBoolPtr(true),
DeleteMarkerVersionId: out.Deleted[1].VersionId,
VersionId: out.Deleted[1].VersionId,
},
}

Expand Down

0 comments on commit 2b9111f

Please sign in to comment.