mirror of
https://github.com/minio/minio.git
synced 2025-01-27 06:33:18 -05:00
XL/DeleteObject: delete call on a prefix should not delete the entire tree structure. (#1916)
fixes #1915
This commit is contained in:
parent
f51d34cedd
commit
365f80efa3
@ -362,7 +362,7 @@ func (s *MyAPISuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/deletebucketobject/myobject", 0, nil)
|
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/deletebucketobject/prefix/myobject", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
@ -370,7 +370,15 @@ func (s *MyAPISuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucketobject/myobject", 0, nil)
|
// Should not delete "prefix/myobject"
|
||||||
|
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucketobject/prefix", 0, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
|
|
||||||
|
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucketobject/prefix/myobject", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
@ -378,7 +386,7 @@ func (s *MyAPISuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
|
|
||||||
// Delete non existent object should return http.StatusNoContent.
|
// Delete non existent object should return http.StatusNoContent.
|
||||||
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucketobject/myobject1", 0, nil)
|
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucketobject/prefix/myobject1", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
|
@ -369,7 +369,7 @@ func (s *MyAPIXLSuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = s.newRequest("PUT", testAPIXLServer.URL+"/deletebucketobject/myobject", 0, nil)
|
request, err = s.newRequest("PUT", testAPIXLServer.URL+"/deletebucketobject/prefix/myobject", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
@ -377,7 +377,15 @@ func (s *MyAPIXLSuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = s.newRequest("HEAD", testAPIXLServer.URL+"/deletebucketobject/myobject", 0, nil)
|
// Should not delete "prefix/myobject"
|
||||||
|
request, err = s.newRequest("DELETE", testAPIXLServer.URL+"/deletebucketobject/prefix", 0, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
|
|
||||||
|
request, err = s.newRequest("HEAD", testAPIXLServer.URL+"/deletebucketobject/prefix/myobject", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
@ -385,7 +393,15 @@ func (s *MyAPIXLSuite) TestDeleteObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = s.newRequest("DELETE", testAPIXLServer.URL+"/deletebucketobject/myobject", 0, nil)
|
request, err = s.newRequest("DELETE", testAPIXLServer.URL+"/deletebucketobject/prefix/myobject", 0, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
|
|
||||||
|
// Delete of non-existant data should return success.
|
||||||
|
request, err = s.newRequest("DELETE", testAPIXLServer.URL+"/deletebucketobject/prefix/myobject1", 0, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
|
@ -446,6 +446,10 @@ func (xl xlObjects) DeleteObject(bucket, object string) (err error) {
|
|||||||
nsMutex.Lock(bucket, object)
|
nsMutex.Lock(bucket, object)
|
||||||
defer nsMutex.Unlock(bucket, object)
|
defer nsMutex.Unlock(bucket, object)
|
||||||
|
|
||||||
|
if !xl.isObject(bucket, object) {
|
||||||
|
return ObjectNotFound{bucket, object}
|
||||||
|
}
|
||||||
|
|
||||||
if err = xl.deleteObject(bucket, object); err == errFileNotFound {
|
if err = xl.deleteObject(bucket, object); err == errFileNotFound {
|
||||||
// Its valid to return success if given object is not found.
|
// Its valid to return success if given object is not found.
|
||||||
err = nil
|
err = nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user