mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-03 13:30:36 +00:00
chromium: cache chromium tarball hashes in update script
this patch introduces an in memory cache for the result of hashing a chromium release tarball after recompressing and pruning it. previously updating chromium and ungoogled-chromium to the same chromium version would result in the expensive recompression happening twice.
This commit is contained in:
@@ -201,6 +201,8 @@ def print_updates(channels_old, channels_new):
|
||||
channels = {}
|
||||
last_channels = load_as_json(PIN_PATH)
|
||||
|
||||
src_hash_cache = {}
|
||||
|
||||
|
||||
print(f'GET {RELEASES_URL}', file=sys.stderr)
|
||||
with urlopen(RELEASES_URL) as resp:
|
||||
@@ -240,13 +242,22 @@ with urlopen(RELEASES_URL) as resp:
|
||||
google_chrome_suffix = channel_name
|
||||
|
||||
try:
|
||||
channel['hash'] = prefetch_src_sri_hash(
|
||||
channel_name_to_attr_name(channel_name),
|
||||
release["version"]
|
||||
)
|
||||
version = release["version"]
|
||||
|
||||
if version in src_hash_cache:
|
||||
print(f'Already got hash {src_hash_cache[version]} for {version}, skipping FOD prefetch for {channel_name_to_attr_name(channel_name)}')
|
||||
|
||||
channel["hash"] = src_hash_cache[version]
|
||||
else:
|
||||
channel["hash"] = prefetch_src_sri_hash(
|
||||
channel_name_to_attr_name(channel_name),
|
||||
version
|
||||
)
|
||||
src_hash_cache[version] = channel["hash"]
|
||||
|
||||
channel['hash_deb_amd64'] = nix_prefetch_url(
|
||||
f'{DEB_URL}/google-chrome-{google_chrome_suffix}/' +
|
||||
f'google-chrome-{google_chrome_suffix}_{release["version"]}-1_amd64.deb')
|
||||
f'google-chrome-{google_chrome_suffix}_{version}-1_amd64.deb')
|
||||
except subprocess.CalledProcessError:
|
||||
# This release isn't actually available yet. Continue to
|
||||
# the next one.
|
||||
|
||||
Reference in New Issue
Block a user