implement list parts

This commit is contained in:
Konstantinos Koukopoulos 2013-09-30 12:09:35 +03:00
commit 9746e72e1d
2 changed files with 57 additions and 6 deletions

View file

@ -63,12 +63,8 @@ class FakeMultipart(object):
def complete(self):
total = bytearray()
for part_id, index in enumerate(sorted(self.parts.keys()), start=1):
# Make sure part ids are continuous
if part_id != index:
return
total.extend(self.parts[part_id].value)
for part in self.list_parts():
total.extend(part.value)
if len(total) < 5242880:
return
@ -83,6 +79,17 @@ class FakeMultipart(object):
self.parts[part_id] = key
return key
def list_parts(self):
parts = []
for part_id, index in enumerate(sorted(self.parts.keys()), start=1):
# Make sure part ids are continuous
if part_id != index:
return
parts.append(self.parts[part_id])
return parts
class FakeBucket(object):
def __init__(self, name):
@ -156,6 +163,10 @@ class S3Backend(BaseBackend):
return self.set_key(bucket_name, multipart.key_name, value)
def list_multipart(self, bucket_name, multipart_id):
bucket = self.buckets[bucket_name]
return bucket.multiparts[multipart_id].list_parts()
def set_part(self, bucket_name, multipart_id, part_id, value):
bucket = self.buckets[bucket_name]
multipart = bucket.multiparts[multipart_id]