Skip to content
Snippets Groups Projects
Commit 117bffa3 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[mirror] When dry-running, do not update patch file

parent 086cf496
Branches
Tags
No related merge requests found
Pipeline #34683 passed
......@@ -307,25 +307,26 @@ def _cleanup_json(data, packages):
return data
def _save_json(data, dest_dir, arch, name):
def _save_json(data, dest_dir, arch, name, dry_run):
"""Saves contents of conda JSON"""
destfile = os.path.join(dest_dir, arch, name)
with open(destfile, 'w') as outfile:
json.dump(data, outfile, ensure_ascii=True, indent=2)
if not dry_run:
with open(destfile, 'w') as outfile:
json.dump(data, outfile, ensure_ascii=True, indent=2)
return destfile
def copy_and_clean_json(url, dest_dir, arch, name):
def copy_and_clean_json(url, dest_dir, arch, name, dry_run):
"""Copies and cleans conda JSON file"""
data = get_json(url, arch, name)
packages = get_local_contents(dest_dir, arch)
data = _cleanup_json(data, packages)
return _save_json(data, dest_dir, arch, name)
return _save_json(data, dest_dir, arch, name, dry_run)
def copy_and_clean_patch(url, dest_dir, arch, name):
def copy_and_clean_patch(url, dest_dir, arch, name, dry_run):
"""Copies and cleans conda patch_instructions JSON file"""
data = get_json(url, arch, name)
......@@ -336,7 +337,7 @@ def copy_and_clean_patch(url, dest_dir, arch, name):
for key in ["remove", "revoke"]:
data[key] = [k for k in data[key] if k in packages]
return _save_json(data, dest_dir, arch, name)
return _save_json(data, dest_dir, arch, name, dry_run)
def checksum_packages(repodata, dest_dir, arch, packages):
......
......@@ -191,8 +191,8 @@ def mirror(
to_download |= issues
if to_download:
download_packages(to_download, remote_repodata, channel_url, dest_dir,
arch, dry_run)
download_packages(to_download, remote_repodata, channel_url,
dest_dir, arch, dry_run)
else:
echo_info("Mirror at %s/%s is up-to-date w.r.t. %s/%s. " \
"No packages to download." % (dest_dir, arch, channel_url,
......@@ -212,7 +212,7 @@ def mirror(
# to do its magic.
patch_file = 'patch_instructions.json'
name = copy_and_clean_patch(channel_url, dest_dir, arch,
patch_file)
patch_file, dry_run)
echo_info("Cleaned copy of %s/%s/%s installed at %s" %
(channel_url, arch, patch_file, name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment