Merge pull request #375 from akuker/fix_unzipping

Fix incorrect path to zip file to unzip; improve error handling
This commit is contained in:
Eric Helgeson 2021-10-24 13:09:50 -05:00 committed by GitHub
commit 4474f1ddaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -146,13 +146,13 @@ def unzip_file(file_name):
unzip_proc = run(
["unzip", "-d", server_info["image_dir"], "-o", "-j", \
server_info["image_dir"] + file_name], capture_output=True
f"{server_info['image_dir']}/{file_name}"], capture_output=True
)
if unzip_proc.returncode != 0:
logging.warning(f"Unzipping failed: {unzip_proc}")
return {"status": False, "msg": unzip_proc}
return {"status": False, "msg": str(unzip_proc)}
return {"status": True, "msg": f"{file_name} unzipped"}
return {"status": True, "msg": f"Unzipped {file_name} to {server_info['image_dir']}"}
def download_file_to_iso(scsi_id, url):

View File

@ -638,11 +638,13 @@ def delete():
def unzip():
image = request.form.get("image")
if unzip_file(image):
flash("Unzipped file " + image)
process = unzip_file(image)
if process["status"]:
flash(process["msg"])
return redirect(url_for("index"))
else:
flash("Failed to unzip " + image, "error")
flash(process["msg"], "error")
return redirect(url_for("index"))