Merge "fix when deleting a versioned object when the version target container is missing"
This commit is contained in:
@@ -1397,19 +1397,18 @@ class ObjectController(Controller):
|
|||||||
lcontainer = object_versions.split('/')[0]
|
lcontainer = object_versions.split('/')[0]
|
||||||
prefix_len = '%03x' % len(self.object_name)
|
prefix_len = '%03x' % len(self.object_name)
|
||||||
lprefix = prefix_len + self.object_name + '/'
|
lprefix = prefix_len + self.object_name + '/'
|
||||||
|
last_item = None
|
||||||
try:
|
try:
|
||||||
raw_listing = self._listing_iter(lcontainer, lprefix,
|
for last_item in self._listing_iter(lcontainer, lprefix,
|
||||||
req.environ)
|
req.environ):
|
||||||
|
pass
|
||||||
except ListingIterNotFound:
|
except ListingIterNotFound:
|
||||||
# set raw_listing so that the actual object is deleted
|
# no worries, last_item is None
|
||||||
raw_listing = []
|
pass
|
||||||
except ListingIterNotAuthorized, err:
|
except ListingIterNotAuthorized, err:
|
||||||
return err.aresp
|
return err.aresp
|
||||||
except ListingIterError:
|
except ListingIterError:
|
||||||
return HTTPServerError(request=req)
|
return HTTPServerError(request=req)
|
||||||
last_item = None
|
|
||||||
for item in raw_listing: # find the last item
|
|
||||||
last_item = item
|
|
||||||
if last_item:
|
if last_item:
|
||||||
# there are older versions so copy the previous version to the
|
# there are older versions so copy the previous version to the
|
||||||
# current object and delete the previous version
|
# current object and delete the previous version
|
||||||
|
|||||||
@@ -2635,6 +2635,46 @@ class TestObjectController(unittest.TestCase):
|
|||||||
versions = [x for x in body.split('\n') if x]
|
versions = [x for x in body.split('\n') if x]
|
||||||
self.assertEquals(len(versions), 1)
|
self.assertEquals(len(versions), 1)
|
||||||
|
|
||||||
|
# Check for when the versions target container doesn't exist
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile()
|
||||||
|
fd.write('PUT /v1/a/whoops HTTP/1.1\r\nHost: localhost\r\n'
|
||||||
|
'Connection: close\r\nX-Storage-Token: t\r\n'
|
||||||
|
'Content-Length: 0\r\nX-Versions-Location: none\r\n\r\n')
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = 'HTTP/1.1 201'
|
||||||
|
self.assertEquals(headers[:len(exp)], exp)
|
||||||
|
# Create the versioned file
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile()
|
||||||
|
fd.write('PUT /v1/a/whoops/foo HTTP/1.1\r\nHost: '
|
||||||
|
'localhost\r\nConnection: close\r\nX-Storage-Token: '
|
||||||
|
't\r\nContent-Length: 5\r\n\r\n00000\r\n')
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = 'HTTP/1.1 201'
|
||||||
|
self.assertEquals(headers[:len(exp)], exp)
|
||||||
|
# Create another version
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile()
|
||||||
|
fd.write('PUT /v1/a/whoops/foo HTTP/1.1\r\nHost: '
|
||||||
|
'localhost\r\nConnection: close\r\nX-Storage-Token: '
|
||||||
|
't\r\nContent-Length: 5\r\n\r\n00001\r\n')
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = 'HTTP/1.1 412'
|
||||||
|
self.assertEquals(headers[:len(exp)], exp)
|
||||||
|
# Delete the object
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile()
|
||||||
|
fd.write('DELETE /v1/a/whoops/foo HTTP/1.1\r\nHost: '
|
||||||
|
'localhost\r\nConnection: close\r\nX-Storage-Token: t\r\n\r\n')
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = 'HTTP/1.1 2' # 2xx response
|
||||||
|
self.assertEquals(headers[:len(exp)], exp)
|
||||||
|
|
||||||
def test_chunked_put_lobjects(self):
|
def test_chunked_put_lobjects(self):
|
||||||
# Create a container for our segmented/manifest object testing
|
# Create a container for our segmented/manifest object testing
|
||||||
(prolis, acc1lis, acc2lis, con2lis, con2lis, obj1lis, obj2lis) = \
|
(prolis, acc1lis, acc2lis, con2lis, con2lis, obj1lis, obj2lis) = \
|
||||||
|
|||||||
Reference in New Issue
Block a user