Changeset View
Changeset View
Standalone View
Standalone View
swh/web/utils/archive.py
Show First 20 Lines • Show All 1,091 Lines • ▼ Show 20 Lines | ) -> Dict[str, int]: | ||||
branch_counts = storage.snapshot_count_branches( | branch_counts = storage.snapshot_count_branches( | ||||
snapshot_id_bin, | snapshot_id_bin, | ||||
branch_name_exclude_prefix.encode() if branch_name_exclude_prefix else None, | branch_name_exclude_prefix.encode() if branch_name_exclude_prefix else None, | ||||
) | ) | ||||
# remove possible None key returned by snapshot_count_branches | # remove possible None key returned by snapshot_count_branches | ||||
# when null branches are present in the snapshot | # when null branches are present in the snapshot | ||||
branch_counts.pop(None, None) | branch_counts.pop(None, None) | ||||
snapshot_sizes.update(branch_counts) | snapshot_sizes.update(branch_counts) | ||||
snapshot_sizes["branch"] = sum( | |||||
snapshot_sizes.get(target_type, 0) | |||||
for target_type in ("content", "directory", "revision") | |||||
) | |||||
return snapshot_sizes | return snapshot_sizes | ||||
def lookup_snapshot( | def lookup_snapshot( | ||||
snapshot_id: str, | snapshot_id: str, | ||||
branches_from: str = "", | branches_from: str = "", | ||||
branches_count: int = 1000, | branches_count: int = 1000, | ||||
target_types: Optional[List[str]] = None, | target_types: Optional[List[str]] = None, | ||||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |