Unzip zipfiles before storing to iso (#525)

* Unzip zipfiles before storing to iso

* Add helptext

* Skip unzip for MacZip format

* Should not be an fstring
This commit is contained in:
Daniel Markstedt 2021-12-19 15:46:22 -08:00 committed by GitHub
parent 39bc485671
commit 7efa895239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -242,6 +242,7 @@ def download_file_to_iso(url, *iso_args):
"""
from time import time
from subprocess import run, CalledProcessError
import asyncio
server_info = get_server_info()
@ -257,6 +258,25 @@ def download_file_to_iso(url, *iso_args):
if not req_proc["status"]:
return {"status": False, "msg": req_proc["msg"]}
from zipfile import is_zipfile, ZipFile
if is_zipfile(tmp_full_path):
if "XtraStuf.mac" in str(ZipFile(tmp_full_path).namelist()):
logging.info("MacZip file format detected. Will not unzip to retain resource fork.")
else:
logging.info(
"%s is a zipfile! Will attempt to unzip and store the resulting files.",
tmp_full_path,
)
unzip_proc = asyncio.run(run_async(
f"unzip -d {tmp_dir} -n {tmp_full_path}"
))
if not unzip_proc["returncode"]:
logging.info(
"%s was successfully unzipped. Deleting the zipfile.",
tmp_full_path,
)
delete_file(tmp_full_path)
try:
iso_proc = (
run(
@ -265,7 +285,7 @@ def download_file_to_iso(url, *iso_args):
*iso_args,
"-o",
iso_filename,
tmp_full_path,
tmp_dir,
],
capture_output=True,
check=True,

View File

@ -448,6 +448,7 @@
<li>HFS is for Mac OS, Joliet for Windows, and Rock Ridge for POSIX.</li>
<li>On Mac OS, requires a <a href="https://github.com/akuker/RASCSI/wiki/Drive-Setup#Mounting_CD_ISO_or_MO_images">compatible CD-ROM driver</a> installed on the target system.
</li>
<li>If the target file is a zip archive, we will attempt to unzip it and store the resulting files only.</li>
</ul>
</details>
<table style="border: none">