Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | def content_add(self, content: List[Content]) -> Dict: | ||||
return { | return { | ||||
"content:add": len(contents), | "content:add": len(contents), | ||||
"content:add:bytes": objstorage_summary["content:add:bytes"], | "content:add:bytes": objstorage_summary["content:add:bytes"], | ||||
} | } | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def content_update(self, content, keys=[], db=None, cur=None): | def content_update( | ||||
self, contents: List[Dict[str, Any]], keys: List[str] = [], db=None, cur=None | |||||
) -> None: | |||||
# TODO: Add a check on input keys. How to properly implement | # TODO: Add a check on input keys. How to properly implement | ||||
# this? We don't know yet the new columns. | # this? We don't know yet the new columns. | ||||
self.journal_writer.content_update(content) | self.journal_writer.content_update(contents) | ||||
db.mktemp("content", cur) | db.mktemp("content", cur) | ||||
select_keys = list(set(db.content_get_metadata_keys).union(set(keys))) | select_keys = list(set(db.content_get_metadata_keys).union(set(keys))) | ||||
with convert_validation_exceptions(): | with convert_validation_exceptions(): | ||||
db.copy_to(content, "tmp_content", select_keys, cur) | db.copy_to(contents, "tmp_content", select_keys, cur) | ||||
db.content_update_from_temp(keys_to_update=keys, cur=cur) | db.content_update_from_temp(keys_to_update=keys, cur=cur) | ||||
@timed | @timed | ||||
@process_metrics | @process_metrics | ||||
@db_transaction() | @db_transaction() | ||||
def content_add_metadata(self, content: List[Content], db=None, cur=None) -> Dict: | def content_add_metadata(self, content: List[Content], db=None, cur=None) -> Dict: | ||||
missing = self.content_missing( | missing = self.content_missing( | ||||
(c.to_dict() for c in content), key_hash="sha1_git", db=db, cur=cur, | (c.to_dict() for c in content), key_hash="sha1_git", db=db, cur=cur, | ||||
▲ Show 20 Lines • Show All 1,156 Lines • Show Last 20 Lines |