Handle deleted files with if-none-match
When an object is deleted, we retrieve its metadata on the next PUT requests, which make if-none-match requests fail while the object shouldn't be here. It seems we're only interested in the timestamp of the deleted object, so get that but forget the metadata. Change-Id: I4a4a8be9b631598ca1cd52c53885c68c3fbdfc4a Closes-Bug: #1640448
This commit is contained in:
parent
0873b7c03e
commit
2bdf61fadd
@ -686,7 +686,7 @@ class ObjectController(BaseStorageServer):
|
||||
except DiskFileXattrNotSupported:
|
||||
return HTTPInsufficientStorage(drive=device, request=request)
|
||||
except DiskFileDeleted as e:
|
||||
orig_metadata = e.metadata
|
||||
orig_metadata = {}
|
||||
orig_timestamp = e.timestamp
|
||||
except (DiskFileNotExist, DiskFileQuarantined):
|
||||
orig_metadata = {}
|
||||
|
@ -273,6 +273,12 @@ class TestObject(unittest2.TestCase):
|
||||
})
|
||||
|
||||
def test_if_none_match(self):
|
||||
def delete(url, token, parsed, conn):
|
||||
conn.request('DELETE', '%s/%s/%s' % (
|
||||
parsed.path, self.container, 'if_none_match_test'), '',
|
||||
{'X-Auth-Token': token})
|
||||
return check_response(conn)
|
||||
|
||||
def put(url, token, parsed, conn):
|
||||
conn.request('PUT', '%s/%s/%s' % (
|
||||
parsed.path, self.container, 'if_none_match_test'), '',
|
||||
@ -287,6 +293,13 @@ class TestObject(unittest2.TestCase):
|
||||
resp.read()
|
||||
self.assertEqual(resp.status, 412)
|
||||
|
||||
resp = retry(delete)
|
||||
resp.read()
|
||||
self.assertEqual(resp.status, 204)
|
||||
resp = retry(put)
|
||||
resp.read()
|
||||
self.assertEqual(resp.status, 201)
|
||||
|
||||
def put(url, token, parsed, conn):
|
||||
conn.request('PUT', '%s/%s/%s' % (
|
||||
parsed.path, self.container, 'if_none_match_test'), '',
|
||||
|
Loading…
Reference in New Issue
Block a user