mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-10 03:53:56 -06:00
refactor: split helpers out of grown functions
This commit is contained in:
1 parent
ba7c185d8a
commit
d8ad89902b
8 files changed
+183
-104
No files matched your search
+13
-1
@@ -163,7 +163,7 @@ def _fetch_asset(
|
||||
hashes, expected_sha1, expected_md5
|
||||
):
|
||||
return cached
|
||||
elif offline or _served_size(name) in (None, os.path.getsize(cached)):
|
||||
elif not _replaced_on_release(name, cached, offline):
|
||||
# A copy of this asset that answers another hash: the caller
|
||||
# wants a different revision under the same name, and the
|
||||
# release still serves this one. Keeping it is what lets the
|
||||
@@ -234,6 +234,18 @@ def _asset_urls(name: str) -> list[tuple[str, str]]:
|
||||
]
|
||||
|
||||
|
||||
def _replaced_on_release(name: str, cached: str, offline: bool) -> bool:
|
||||
"""Whether the release now serves other bytes than the cached copy.
|
||||
|
||||
Sizes are compared, as check_release_assets does: a request per asset,
|
||||
no download. Offline or unreadable, the copy is assumed current.
|
||||
"""
|
||||
if offline:
|
||||
return False
|
||||
served = _served_size(name)
|
||||
return served is not None and served != os.path.getsize(cached)
|
||||
|
||||
|
||||
def _served_size(name: str) -> int | None:
|
||||
"""Size of the asset the release serves now, or None when unreadable."""
|
||||
for candidate, url in _asset_urls(name):
|
||||
|
||||
Reference in new issue
Block a user