Fixed deletes for failed tests

test_multi_object_delete
test_multi_objectv2_delete

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-04-04 15:38:27 +04:00 committed by Alex Vanin
parent e319f2422e
commit ed47bc1596
2 changed files with 16 additions and 18 deletions

View file

@ -213,19 +213,7 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re
var errs []error
for _, obj := range deletedObjects {
if obj.Error == nil {
deletedObj := DeletedObject{
ObjectIdentifier: ObjectIdentifier{
ObjectName: obj.Name,
VersionID: obj.VersionID,
},
DeleteMarkerVersionID: obj.DeleteMarkVersion,
}
if deletedObj.DeleteMarkerVersionID != "" {
deletedObj.DeleteMarker = true
}
response.DeletedObjects = append(response.DeletedObjects, deletedObj)
} else if !requested.Quiet {
if obj.Error != nil {
code := "BadRequest"
if s3err, ok := obj.Error.(errors.Error); ok {
code = s3err.Code
@ -237,15 +225,26 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re
VersionID: obj.VersionID,
})
errs = append(errs, obj.Error)
} else if !requested.Quiet {
deletedObj := DeletedObject{
ObjectIdentifier: ObjectIdentifier{
ObjectName: obj.Name,
VersionID: obj.VersionID,
},
DeleteMarkerVersionID: obj.DeleteMarkVersion,
}
if deletedObj.DeleteMarkerVersionID != "" {
deletedObj.DeleteMarker = true
}
response.DeletedObjects = append(response.DeletedObjects, deletedObj)
}
}
if !requested.Quiet && len(errs) != 0 {
additional := []zap.Field{
if len(errs) != 0 {
fields := []zap.Field{
zap.Array("objects", marshaler),
zap.Errors("errors", errs),
}
h.logAndSendError(w, "could not delete objects", reqInfo, nil, additional...)
h.log.Error("couldn't delete objects", fields...)
}
if err := api.EncodeToResponse(w, response); err != nil {

View file

@ -568,7 +568,6 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings
}
last := versions.getLast(FromUnversioned())
if last == nil {
obj.Error = errors.GetAPIError(errors.ErrInvalidVersion)
return obj
}
p.Header[VersionsDeleteMarkAttr] = last.Version()