cmd-decompress: skip over missing artifacts
In the `cosa buildfetch` workflow, it's expected that we only fetch some
artifacts. Allow missing artifacts unless it was explicitly requested.
@@ -189,6 +189,7 @@ def uncompress_one_builddir(builddir):
if len(args.artifact) > 0:
only_artifacts = set(args.artifact)
+ skipped_missing = []
for img_format, img in buildmeta['images'].items():
if img.get('skip-compression', False):
print(f"Skipping {img_format}")
@@ -198,6 +199,10 @@ def uncompress_one_builddir(builddir):
file = img['path']
filepath = os.path.join(builddir, file)
+ if not os.path.exists(filepath) and only_artifacts is None:
+ skipped_missing += [img_format]
+ continue
+
# uncompress only compressed files
if file.endswith(tuple(ext_dict.values())):
tmpfile = os.path.join(tmpdir, strip_ext(file))
@@ -241,6 +246,8 @@ def uncompress_one_builddir(builddir):
# try to delete the original file if it's somehow still around
rm_allow_noent(filepath[:-3])
+ if len(skipped_missing) > 0:
+ print(f"Skipped missing artifacts: {skipped_missing}")
if at_least_one:
print(f"Updated: {buildmeta_path}")
return at_least_one
