Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | def content_add_metadata(self, content: List[Content], db=None, cur=None) -> Dict: | ||||
self.journal_writer.content_add_metadata(contents) | self.journal_writer.content_add_metadata(contents) | ||||
self._content_add_metadata(db, cur, contents) | self._content_add_metadata(db, cur, contents) | ||||
return { | return { | ||||
"content:add": len(contents), | "content:add": len(contents), | ||||
} | } | ||||
@timed | @timed | ||||
def content_get(self, content): | def content_get( | ||||
self, contents: List[bytes] | |||||
) -> Iterable[Optional[Dict[str, bytes]]]: | |||||
# FIXME: Make this method support slicing the `data`. | # FIXME: Make this method support slicing the `data`. | ||||
if len(content) > BULK_BLOCK_CONTENT_LEN_MAX: | if len(contents) > BULK_BLOCK_CONTENT_LEN_MAX: | ||||
raise StorageArgumentException( | raise StorageArgumentException( | ||||
"Send at maximum %s contents." % BULK_BLOCK_CONTENT_LEN_MAX | f"Send at maximum {BULK_BLOCK_CONTENT_LEN_MAX} contents." | ||||
) | ) | ||||
yield from self.objstorage.content_get(content) | yield from self.objstorage.content_get(contents) | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def content_get_range(self, start, end, limit=1000, db=None, cur=None): | def content_get_range(self, start, end, limit=1000, db=None, cur=None): | ||||
if limit is None: | if limit is None: | ||||
raise StorageArgumentException("limit should not be None") | raise StorageArgumentException("limit should not be None") | ||||
contents = [] | contents = [] | ||||
next_content = None | next_content = None | ||||
▲ Show 20 Lines • Show All 1,130 Lines • Show Last 20 Lines |