S3-layer: Multiple-delete should return success for non-existent objects. (#2633)

Fixes #2630
This commit is contained in:
Krishna Srinivas 2016-09-08 00:19:12 +05:30 committed by Harshavardhana
parent afe874f15a
commit a4afb312d4
2 changed files with 13 additions and 1 deletions

View File

@ -267,6 +267,12 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
deletedObjects = append(deletedObjects, object) deletedObjects = append(deletedObjects, object)
continue continue
} }
if _, ok := err.(ObjectNotFound); ok {
// If the object is not found it should be
// accounted as deleted as per S3 spec.
deletedObjects = append(deletedObjects, object)
continue
}
errorIf(err, "Unable to delete object. %s", object.ObjectName) errorIf(err, "Unable to delete object. %s", object.ObjectName)
// Error during delete should be collected separately. // Error during delete should be collected separately.
deleteErrors = append(deleteErrors, DeleteError{ deleteErrors = append(deleteErrors, DeleteError{

View File

@ -347,6 +347,11 @@ func (s *TestSuiteCommon) TestDeleteMultipleObjects(c *C) {
ObjectName: objName, ObjectName: objName,
}) })
} }
// Append a non-existent object for which the response should be marked
// as deleted.
delObjReq.Objects = append(delObjReq.Objects, ObjectIdentifier{
ObjectName: fmt.Sprintf("%d/%s", 10, objectName),
})
// Marshal delete request. // Marshal delete request.
deleteReqBytes, err := xml.Marshal(delObjReq) deleteReqBytes, err := xml.Marshal(delObjReq)
@ -367,7 +372,8 @@ func (s *TestSuiteCommon) TestDeleteMultipleObjects(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
err = xml.Unmarshal(delRespBytes, &deleteResp) err = xml.Unmarshal(delRespBytes, &deleteResp)
c.Assert(err, IsNil) c.Assert(err, IsNil)
for i := 0; i < 10; i++ { for i := 0; i <= 10; i++ {
// All the objects should be under deleted list (including non-existent object)
c.Assert(deleteResp.DeletedObjects[i], DeepEquals, delObjReq.Objects[i]) c.Assert(deleteResp.DeletedObjects[i], DeepEquals, delObjReq.Objects[i])
} }
c.Assert(len(deleteResp.Errors), Equals, 0) c.Assert(len(deleteResp.Errors), Equals, 0)