Skip to content

Commit

Permalink
Merge pull request #28 from haiwen/fix_list_objects
Browse files Browse the repository at this point in the history
Fix the bug that list_objects can't return all objects.
  • Loading branch information
killing authored Oct 31, 2018
2 parents 5fd0169 + 8c755e7 commit 7fa7f01
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions seafobj/backends/alioss.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,29 @@ def get_name(self):
return 'OSS storage backend'

def list_objs(self, repo_id=None):
if repo_id != None:
Simp_obj_info = self.oss_client.bucket.list_objects(repo_id)
else:
Simp_obj_info = self.oss_client.bucket.list_objects()
object_list = []
next_marker = ''
while (1):
if repo_id != None:
Simp_obj_info = self.oss_client.bucket.list_objects(repo_id, '',next_marker)
else:
Simp_obj_info = self.oss_client.bucket.list_objects('', '', next_marker)

for key in Simp_obj_info.object_list:
token = key.key.split('/')
if len(token) == 2:
repo_id = token[0]
obj_id = token[1]
size = key.size
obj = [repo_id, obj_id, size]
yield obj
object_list = Simp_obj_info.object_list

for key in object_list:
token = key.key.split('/')
if len(token) == 2:
repo_id = token[0]
obj_id = token[1]
size = key.size
obj = [repo_id, obj_id, size]
yield obj

if Simp_obj_info.is_truncated == False:
break
else:
next_marker = Simp_obj_info.next_marker

def obj_exists(self, repo_id, obj_id):
key = '%s/%s' % (repo_id, obj_id)
Expand Down

0 comments on commit 7fa7f01

Please sign in to comment.