Skip to content

Commit

Permalink
Merge d6f118b into 3ef20cf
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkinsc committed Jun 11, 2019
2 parents 3ef20cf + d6f118b commit 588ef62
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,19 @@ def extract_tarball(tarfile, out_dir=None, threads=None, compression='auto', pip

if compression == 'zip':
assert tarfile != '-'
# if zip file needs to be repaired
# zip -FFv file.zip --out file.fixed.zip
cmd = ['unzip', '-q', tarfile, '-d', out_dir]
with open(os.devnull, 'w') as fnull:
subprocess.check_call(cmd, stderr=fnull)
try:
with open(os.devnull, 'w') as fnull:
subprocess.check_call(cmd, stderr=fnull)
except subprocess.CalledProcessError as e:
fixed_archive = os.path.join(out_dir,os.path.basename(tarfile)+".fixed.zip")
repair_cmd = ['zip', '-FFv', tarfile, '--out', fixed_archive]
cmd = ['unzip', '-q', fixed_archive, '-d', out_dir]
with open(os.devnull, 'w') as fnull:
subprocess.check_call(repair_cmd, stderr=fnull)
subprocess.check_call(cmd, stderr=fnull)
else:
if compression == 'gz':
decompressor = ['pigz', '-dc', '-p', str(util.misc.sanitize_thread_count(threads))]
Expand Down

0 comments on commit 588ef62

Please sign in to comment.