Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 608 Lines • ▼ Show 20 Lines | def content_missing_per_sha1(self, contents, db=None, cur=None): | ||||
Raises: | Raises: | ||||
TODO: an exception when we get a hash collision. | TODO: an exception when we get a hash collision. | ||||
""" | """ | ||||
for obj in db.content_missing_per_sha1(contents, cur): | for obj in db.content_missing_per_sha1(contents, cur): | ||||
yield obj[0] | yield obj[0] | ||||
@remote_api_endpoint('content/missing/sha1_git') | |||||
@timed | |||||
@db_transaction_generator() | |||||
def content_missing_per_sha1_git(self, contents, db=None, cur=None): | |||||
"""List content missing from storage based only on sha1_git. | |||||
Args: | |||||
contents (Iterable): An iterable of content id (sha1_git) | |||||
Yields: | |||||
missing contents sha1_git | |||||
""" | |||||
for obj in db.content_missing_per_sha1_git(contents, cur): | |||||
yield obj[0] | |||||
@remote_api_endpoint('content/skipped/missing') | @remote_api_endpoint('content/skipped/missing') | ||||
@timed | @timed | ||||
@db_transaction_generator() | @db_transaction_generator() | ||||
def skipped_content_missing(self, contents, db=None, cur=None): | def skipped_content_missing(self, contents, db=None, cur=None): | ||||
"""List skipped_content missing from storage | """List skipped_content missing from storage | ||||
Args: | Args: | ||||
content: iterable of dictionaries containing the data for each | content: iterable of dictionaries containing the data for each | ||||
▲ Show 20 Lines • Show All 550 Lines • ▼ Show 20 Lines | def snapshot_add(self, snapshots, db=None, cur=None): | ||||
if self.journal_writer: | if self.journal_writer: | ||||
self.journal_writer.write_addition('snapshot', snapshot) | self.journal_writer.write_addition('snapshot', snapshot) | ||||
db.snapshot_add(snapshot['id'], cur) | db.snapshot_add(snapshot['id'], cur) | ||||
count += 1 | count += 1 | ||||
return {'snapshot:add': count} | return {'snapshot:add': count} | ||||
@remote_api_endpoint('snapshot/missing') | |||||
@timed | |||||
@db_transaction_generator() | |||||
def snapshot_missing(self, snapshots, db=None, cur=None): | |||||
"""List snapshots missing from storage | |||||
Args: | |||||
snapshots (iterable): an iterable of snapshot ids | |||||
Yields: | |||||
missing snapshot ids | |||||
""" | |||||
for obj in db.snapshot_missing_from_list(snapshots, cur): | |||||
yield obj[0] | |||||
@remote_api_endpoint('snapshot') | @remote_api_endpoint('snapshot') | ||||
@timed | @timed | ||||
@db_transaction(statement_timeout=2000) | @db_transaction(statement_timeout=2000) | ||||
def snapshot_get(self, snapshot_id, db=None, cur=None): | def snapshot_get(self, snapshot_id, db=None, cur=None): | ||||
"""Get the content, possibly partial, of a snapshot with the given id | """Get the content, possibly partial, of a snapshot with the given id | ||||
The branches of the snapshot are iterated in the lexicographical | The branches of the snapshot are iterated in the lexicographical | ||||
order of their names. | order of their names. | ||||
▲ Show 20 Lines • Show All 950 Lines • Show Last 20 Lines |