source/ostree: fix download only case
Source, for compatability reasons, have two modes: download only and download and export. The difference is the arguments that are passed to the source: For download only, the `output` param is empty. In this case also `checksums` *can* be empty and if so it means everything, i.e. the commits, should be fetched. The latter was not properly handled so far. Adjust the logic, which now closely mimics that of the `org.osbuild.curl` source to fix this case. Also catch exceptions invoking `ostree` and properly return them via the json error messaging.
This commit is contained in:
parent
c616afa87e
commit
b609bb81dd
1 changed files with 14 additions and 4 deletions
|
|
@ -128,14 +128,24 @@ def export(checksums, cache, output):
|
|||
|
||||
def main(commits, options, checksums, cache, output):
|
||||
cache = os.path.join(cache, "org.osbuild.ostree")
|
||||
download_only = not output
|
||||
|
||||
if not commits:
|
||||
commits = options.get("commits", {})
|
||||
|
||||
os.makedirs(cache, exist_ok=True)
|
||||
download(commits, checksums, cache)
|
||||
if commits:
|
||||
if not checksums and download_only:
|
||||
checksums = [k for k, _ in commits.items()]
|
||||
|
||||
if not output:
|
||||
os.makedirs(cache, exist_ok=True)
|
||||
try:
|
||||
download(commits, checksums, cache)
|
||||
except subprocess.CalledProcessError as e:
|
||||
output = e.output.strip()
|
||||
json.dump({"error": output}, sys.stdout)
|
||||
return 1
|
||||
|
||||
if download_only:
|
||||
json.dump({}, sys.stdout)
|
||||
return 0
|
||||
|
||||
|
|
@ -151,5 +161,5 @@ if __name__ == '__main__':
|
|||
source_args["options"],
|
||||
source_args["checksums"],
|
||||
source_args["cache"],
|
||||
source_args["output"])
|
||||
source_args.get("output"))
|
||||
sys.exit(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue