diff options
-rwxr-xr-x | bin/just-mr.py | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/bin/just-mr.py b/bin/just-mr.py index f09c82cd..97eb2642 100755 --- a/bin/just-mr.py +++ b/bin/just-mr.py @@ -262,29 +262,16 @@ def archive_tree_id_file(content, repo_type): return os.path.join(ROOT, "tree-map", repo_type, content) -def archive_checkout(desc, repo_type="archive", *, fetch_only=False): - content_id = desc["content"] - target = archive_checkout_dir(content_id, repo_type=repo_type) - if ALWAYS_FILE and os.path.exists(target): - return ["file", subdir_path(target, desc)] - tree_id_file = archive_tree_id_file(content_id, repo_type=repo_type) - if (not ALWAYS_FILE) and os.path.exists(tree_id_file): - with open(tree_id_file) as f: - archive_tree_id = f.read() - return [ - "git tree", - git_subtree(tree=archive_tree_id, - subdir=desc.get("subdir", "."), - upstream=None), - git_root(upstream=None), - ] - if not is_in_cas(content_id): +def archive_fetch(desc, content): + """ Makes sure archive is available and accounted for in cas + """ + if not is_in_cas(content): distfile = desc.get("distfile") if not distfile: distfile = os.path.basename(desc.get("fetch")) if distfile: add_distfile_to_cas(distfile) - if not is_in_cas(content_id): + if not is_in_cas(content): url = desc["fetch"] data = subprocess.run(["wget", "-O", "-", url], stdout=subprocess.PIPE).stdout @@ -299,9 +286,27 @@ def archive_checkout(desc, repo_type="archive", *, fetch_only=False): fail("SHA512 mismatch for %s, expected %s, found %s" % (url, desc["sha512"], actual_hash)) add_to_cas(data) - if not is_in_cas(content_id): - fail("Failed to fetch a file with id %s from %s" % - (content_id, url)) + if not is_in_cas(content): + fail("Failed to fetch a file with id %s from %s" % (content, url)) + + +def archive_checkout(desc, repo_type="archive", *, fetch_only=False): + content_id = desc["content"] + target = archive_checkout_dir(content_id, repo_type=repo_type) + if ALWAYS_FILE and os.path.exists(target): + return ["file", subdir_path(target, desc)] + tree_id_file = archive_tree_id_file(content_id, repo_type=repo_type) + if (not ALWAYS_FILE) and os.path.exists(tree_id_file): + with open(tree_id_file) as f: + archive_tree_id = f.read() + return [ + "git tree", + git_subtree(tree=archive_tree_id, + subdir=desc.get("subdir", "."), + upstream=None), + git_root(upstream=None), + ] + archive_fetch(desc, content=content_id) if fetch_only: return if not ALWAYS_FILE: |