Skip to content
Snippets Groups Projects
Commit 3f620ca6 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

Fix the get_file archive extraction feature.

parent 78264921
No related branches found
No related tags found
1 merge request!148Fix the archive extraction feature
Pipeline #67797 failed
...@@ -66,7 +66,6 @@ def extract_compressed_file(filename): ...@@ -66,7 +66,6 @@ def extract_compressed_file(filename):
# Uncompressing if it is the case # Uncompressing if it is the case
header, ext = os.path.splitext(filename) header, ext = os.path.splitext(filename)
header, ext = header.lower(), ext.lower() header, ext = header.lower(), ext.lower()
if ext == ".zip": if ext == ".zip":
logger.info("Unziping in {0}".format(filename)) logger.info("Unziping in {0}".format(filename))
_unzip(filename, os.path.dirname(filename)) _unzip(filename, os.path.dirname(filename))
...@@ -279,8 +278,6 @@ def get_file( ...@@ -279,8 +278,6 @@ def get_file(
if download or force: if download or force:
logger.info("Downloading %s", final_filename) logger.info("Downloading %s", final_filename)
download_file_from_possible_urls(urls, final_filename) download_file_from_possible_urls(urls, final_filename)
if extract:
extract_compressed_file(final_filename)
if file_hash is not None and not validate_file( if file_hash is not None and not validate_file(
final_filename, file_hash, algorithm=hash_algorithm final_filename, file_hash, algorithm=hash_algorithm
...@@ -290,6 +287,12 @@ def get_file( ...@@ -290,6 +287,12 @@ def get_file(
f"The downloaded file: {final_filename} has the hash of {found_hash}, but we expected {file_hash}. Please re-do the procedure." f"The downloaded file: {final_filename} has the hash of {found_hash}, but we expected {file_hash}. Please re-do the procedure."
) )
# Finally extract if wanted. This will always extract over what would already exist
# so that if a new version of the archive is downloaded, the extracted folder is
# updated.
if extract:
extract_compressed_file(final_filename)
return final_filename return final_filename
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment