Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | def content_find(self, content, db=None, cur=None): | ||||
sha256=content.get("sha256"), | sha256=content.get("sha256"), | ||||
blake2s256=content.get("blake2s256"), | blake2s256=content.get("blake2s256"), | ||||
cur=cur, | cur=cur, | ||||
) | ) | ||||
return [dict(zip(db.content_find_cols, content)) for content in contents] | return [dict(zip(db.content_find_cols, content)) for content in contents] | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def content_metadata_add( | |||||
self, | |||||
id: str, | |||||
context: Dict[str, Union[str, bytes, int]], | |||||
discovery_date: datetime.datetime, | |||||
authority: Dict[str, Any], | |||||
fetcher: Dict[str, Any], | |||||
format: str, | |||||
metadata: bytes, | |||||
db=None, | |||||
cur=None, | |||||
) -> None: | |||||
self._object_metadata_add( | |||||
"content", | |||||
id, | |||||
context, | |||||
discovery_date, | |||||
authority, | |||||
fetcher, | |||||
format, | |||||
metadata, | |||||
db, | |||||
cur, | |||||
) | |||||
@timed | |||||
@db_transaction() | |||||
def content_metadata_get( | |||||
self, | |||||
id: str, | |||||
authority: Dict[str, str], | |||||
after: Optional[datetime.datetime] = None, | |||||
page_token: Optional[bytes] = None, | |||||
limit: int = 1000, | |||||
db=None, | |||||
cur=None, | |||||
) -> Dict[str, Any]: | |||||
return self._object_metadata_get( | |||||
"content", id, authority, after, page_token, limit, db, cur | |||||
) | |||||
@timed | |||||
@db_transaction() | |||||
def content_get_random(self, db=None, cur=None): | def content_get_random(self, db=None, cur=None): | ||||
return db.content_get_random(cur) | return db.content_get_random(cur) | ||||
@staticmethod | @staticmethod | ||||
def _skipped_content_normalize(d): | def _skipped_content_normalize(d): | ||||
d = d.copy() | d = d.copy() | ||||
if d.get("status") is None: | if d.get("status") is None: | ||||
▲ Show 20 Lines • Show All 1,027 Lines • Show Last 20 Lines |