Skip to content

Commit

Permalink
Include cache metadata on the first line of the repodata cache (#490)
Browse files Browse the repository at this point in the history
Co-authored-by: Jannis Leidel <[email protected]>
  • Loading branch information
chrisburr and jezdez authored Mar 11, 2022
1 parent be41e36 commit 02918c3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions constructor/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def write_repodata(cache_dir, url, full_repodata, used_packages, info):
set(full_repodata.keys()) - {'packages', 'packages.conda', 'removed'}}
used_repodata['packages.conda'] = {}
used_repodata['removed'] = []
# arbitrary old, expired date, so that conda will want to immediately update it
# when not being run in offline mode
used_repodata['_mod'] = "Mon, 07 Jan 2019 15:22:15 GMT"
used_repodata['packages'] = {
k: v for k, v in full_repodata['packages'].items() if v['name'] in NAV_APPS}

Expand All @@ -131,6 +128,18 @@ def write_repodata(cache_dir, url, full_repodata, used_packages, info):
data["md5"] = hash_files([pkg_fn])
used_repodata[key][package] = data

repodata_filename = _cache_fn_url(used_repodata['_url'].rstrip("/"))
# The first line of the JSON should contain cache metadata
# Choose an arbitrary old, expired date, so that conda will want to
# immediately update it when not being run in offline mode
url = used_repodata.pop('_url').rstrip("/")
repodata = json.dumps(used_repodata, indent=2)
repodata_header = json.dumps(
{
"_mod": "Mon, 07 Jan 2019 15:22:15 GMT",
"_url": url,
}
)
repodata = repodata_header[:-1] + "," + repodata[1:]
repodata_filename = _cache_fn_url(url)
with open(join(cache_dir, repodata_filename), 'w') as fh:
json.dump(used_repodata, fh, indent=2)
fh.write(repodata)

0 comments on commit 02918c3

Please sign in to comment.