Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 1,064 Lines • ▼ Show 20 Lines | def snapshot_get_latest(self, origin, allowed_statuses=None, db=None, | ||||
""" | """ | ||||
if isinstance(origin, int): | if isinstance(origin, int): | ||||
origin = self.origin_get({'id': origin}, db=db, cur=cur)['url'] | origin = self.origin_get({'id': origin}, db=db, cur=cur)['url'] | ||||
origin_visit = self.origin_visit_get_latest( | origin_visit = self.origin_visit_get_latest( | ||||
origin, allowed_statuses=allowed_statuses, require_snapshot=True, | origin, allowed_statuses=allowed_statuses, require_snapshot=True, | ||||
db=db, cur=cur) | db=db, cur=cur) | ||||
if origin_visit and origin_visit['snapshot']: | if origin_visit and origin_visit['snapshot']: | ||||
return self.snapshot_get(origin_visit['snapshot'], db=db, cur=cur) | snapshot = self.snapshot_get( | ||||
origin_visit['snapshot'], db=db, cur=cur) | |||||
if not snapshot: | |||||
raise ValueError( | |||||
'last origin visit references an unknown snapshot') | |||||
return snapshot | |||||
@db_transaction(statement_timeout=2000) | @db_transaction(statement_timeout=2000) | ||||
def snapshot_count_branches(self, snapshot_id, db=None, cur=None): | def snapshot_count_branches(self, snapshot_id, db=None, cur=None): | ||||
"""Count the number of branches in the snapshot with the given id | """Count the number of branches in the snapshot with the given id | ||||
Args: | Args: | ||||
snapshot_id (bytes): identifier of the snapshot | snapshot_id (bytes): identifier of the snapshot | ||||
▲ Show 20 Lines • Show All 781 Lines • Show Last 20 Lines |