Commit ae7390c3 authored by Heather Ellsworth's avatar Heather Ellsworth
Browse files

Merge branch 'skip-redownload' into 'master'

Avoid possible redownload if we already fnd an image

Closes #14

See merge request Librem5/librem5-devkit-tools!40
parents 2deff4e3 dd17f51f
......@@ -128,9 +128,20 @@ def stream_file(url, attempts):
return resuming_stream(url, ts, attempts), ts
def needs_download(target, meta):
if not os.path.exists(target):
return True
verify_image(target, meta)
except VerifyImageException:
return True
return False
def download_image(url, target, attempts):
decomp = lzma.LZMADecompressor()"Downloading image from {}".format(url))
# We expect metadata to be right next to the image
meta_yml_url = "{}/{}".format(url.rsplit('/', 1)[0], META_YAML)
......@@ -140,6 +151,11 @@ def download_image(url, target, attempts):
uncompressed_size = int(meta['image']['size'])
logging.debug("Image size is %d", uncompressed_size)
if not needs_download(target, meta):"Image already up to date - no download needed.")
return"Downloading image from {}".format(url))
stream, ts = stream_file(url, attempts)
download_bar = tqdm.tqdm(total=ts,
......@@ -156,8 +172,7 @@ def download_image(url, target, attempts):
if meta:
verify_image(target, meta)
verify_image(target, meta)
def find_image(jobname, type, dist):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment