diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -169,7 +169,7 @@ """ return self._content_add(contents, with_data=False) - def content_get(self, ids): + def content_get(self, ids, start=0, end=-1): """Retrieve in bulk contents and their data. This function may yield more blobs than provided sha1 identifiers, @@ -201,7 +201,10 @@ yield None continue - yield {'sha1': obj_id, 'data': data} + if end != -1: + yield {'sha1': obj_id, 'data': data[start:end]} + else: + yield {'sha1': obj_id, 'data': data} def content_get_range(self, start, end, limit=1000, db=None, cur=None): """Retrieve contents within range [start, end] bound by limit. diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -334,7 +334,7 @@ return summary - def content_get(self, content): + def content_get(self, content, start=0, end=-1): """Retrieve in bulk contents and their data. This generator yields exactly as many items than provided sha1 @@ -369,7 +369,10 @@ yield None continue - yield {'sha1': obj_id, 'data': data} + if end != -1: + yield {'sha1': obj_id, 'data': data[start:end]} + else: + yield {'sha1': obj_id, 'data': data} @db_transaction() def content_get_range(self, start, end, limit=1000, db=None, cur=None):