Merge pull request #368 from akuker/manual_unzip

Bring back manual unzip
This commit is contained in:
Eric Helgeson 2021-10-24 11:53:14 -05:00 committed by GitHub
commit 1b17b8272c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -134,6 +134,16 @@
{% if file["name"] in attached_images %}
<center>Attached!</center>
{% else %}
{% if file["name"].lower().endswith(archive_file_suffix) %}
<form action="/files/unzip" method="post">
<input type="hidden" name="image" value="{{file["name"]}}">
<input type="submit" value="Unzip" />
</form>
<form action="/files/delete" method="post" onsubmit="return confirm('Delete file?')">
<input type="hidden" name="image" value="{{file["name"]}}">
<input type="submit" value="Delete" />
</form>
{% else %}
<form action="/scsi/attach" method="post">
<input type="hidden" name="file_name" value="{{file["name"]}}">
<input type="hidden" name="file_size" value="{{file["size"]}}">
@ -169,6 +179,7 @@
</form>
{% endif %}
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
@ -219,7 +230,7 @@
<details>
<summary>Upload File</summary>
<ul>
<li>Uploads file to <tt>{{base_dir}}</tt>. The largest file size accepted is {{max_file_size}} MB. Zip files will be unzipped.</li>
<li>Uploads file to <tt>{{base_dir}}</tt>. The largest file size accepted is {{max_file_size}} MB.</li>
<li>For unrecognized file types, try renaming hard drive images to '.hds' and CD-ROM images to '.iso' before uploading.</li>
<li>Recognized file types: {{valid_file_suffix}}</li>
</ul>

View File

@ -108,6 +108,7 @@ def index():
device_types=device_types["device_types"],
free_disk=int(disk["free"] / 1024 / 1024),
valid_file_suffix=valid_file_suffix,
archive_file_suffix=ARCHIVE_FILE_SUFFIX,
removable_device_types=REMOVABLE_DEVICE_TYPES,
)
@ -570,13 +571,10 @@ def upload_file():
return make_response(("Transferred file corrupted!", 500))
else:
log.info(f"File {file.filename} has been uploaded successfully")
if filename.lower().endswith(".zip"):
unzip_file(filename)
else:
log.debug(f"Chunk {current_chunk + 1} of {total_chunks} "
f"for file {file.filename} completed.")
return make_response(("File upload successful!", 200))
@ -636,6 +634,18 @@ def delete():
return redirect(url_for("index"))
@app.route("/files/unzip", methods=["POST"])
def unzip():
image = request.form.get("image")
if unzip_file(image):
flash("Unzipped file " + image)
return redirect(url_for("index"))
else:
flash("Failed to unzip " + image, "error")
return redirect(url_for("index"))
@app.route("/files/prop", methods=["POST"])
def show_properties():
file_name = request.form.get("image")