|
10 | 10 | import struct
|
11 | 11 | import sys
|
12 | 12 | from base64 import b64decode
|
13 |
| -from collections.abc import AsyncGenerator, Generator, Sequence |
| 13 | +from collections.abc import AsyncGenerator, Generator, Mapping, Sequence |
14 | 14 | from contextlib import asynccontextmanager
|
15 | 15 | from dataclasses import dataclass, field
|
16 | 16 | from datetime import datetime
|
@@ -777,6 +777,14 @@ def is_depot(item: tuple[str, Any]) -> TypeGuard[tuple[str, manifest.Depot]]:
|
777 | 777 | return True
|
778 | 778 |
|
779 | 779 |
|
| 780 | +def maybe_get(map: Mapping[str, str | None] | str, key: str) -> int | None: |
| 781 | + if isinstance(map, str): |
| 782 | + return int(map) |
| 783 | + value = map.get(key) |
| 784 | + if value is not None: |
| 785 | + return int(value) |
| 786 | + |
| 787 | + |
780 | 788 | class AppInfo(ProductInfo, PartialApp[str]):
|
781 | 789 | """Represents a collection of information on an app."""
|
782 | 790 |
|
@@ -930,17 +938,32 @@ def __init__(
|
930 | 938 | )
|
931 | 939 | )
|
932 | 940 | else:
|
933 |
| - for branch_name, manifest_id in manifests.items(): |
| 941 | + public_manifest_info = manifests["public"] |
| 942 | + public_id = ManifestID( |
| 943 | + int(public_manifest_info if isinstance(public_manifest_info, str) else public_manifest_info["gid"]) |
| 944 | + ) |
| 945 | + for branch_name, manifest_info in manifests.items(): |
934 | 946 | branch = self._branches[branch_name]
|
| 947 | + manifest_id = manifest_info if isinstance(manifest_info, str) else manifest_info["gid"] |
935 | 948 | if not branch.password_required:
|
936 |
| - manifest = ManifestInfo(state, ManifestID(int(manifest_id)), branch=branch) |
| 949 | + manifest = ManifestInfo( |
| 950 | + state, |
| 951 | + ManifestID(int(manifest_id)), |
| 952 | + branch=branch, |
| 953 | + size=maybe_get(manifest_info, "size"), |
| 954 | + download_size=maybe_get(manifest_info, "download"), |
| 955 | + ) |
937 | 956 | else:
|
938 | 957 | encrypted_id = PrivateManifestInfo._get_id(depot, branch)
|
939 | 958 | if encrypted_id is not None:
|
940 | 959 | manifest = PrivateManifestInfo(state, encrypted_id, branch)
|
941 | 960 | else: # fall back to the public version
|
942 | 961 | manifest = ManifestInfo(
|
943 |
| - state, ManifestID(int(manifests["public"])), branch=self.public_branch |
| 962 | + state, |
| 963 | + public_id, |
| 964 | + branch=self.public_branch, |
| 965 | + size=maybe_get(public_manifest_info, "size"), |
| 966 | + download_size=maybe_get(public_manifest_info, "download"), |
944 | 967 | )
|
945 | 968 |
|
946 | 969 | depot_ = Depot(
|
|
0 commit comments