mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-08-25 08:06:39 -07:00
WebHost: Show error instead of 500 for unexpected files in multidata zip (#2260)
* WebHost: Show error instead of 500 for unexpected files in multidata zip * Add filename to error message * Apply suggestions from code review Co-authored-by: black-sliver <[email protected]> --------- Co-authored-by: black-sliver <[email protected]>
This commit is contained in:
co-authored by
black-sliver
parent
d7475ddd73
commit
88dfbd4087
+10
-2
@@ -104,13 +104,21 @@ def upload_zip_to_db(zfile: zipfile.ZipFile, owner=None, meta={"race": False}, s
|
||||
|
||||
# Factorio
|
||||
elif file.filename.endswith(".zip"):
|
||||
_, _, slot_id, *_ = file.filename.split('_')[0].split('-', 3)
|
||||
try:
|
||||
_, _, slot_id, *_ = file.filename.split('_')[0].split('-', 3)
|
||||
except ValueError:
|
||||
flash("Error: Unexpected file found in .zip: " + file.filename)
|
||||
return
|
||||
data = zfile.open(file, "r").read()
|
||||
files[int(slot_id[1:])] = data
|
||||
|
||||
# All other files using the standard MultiWorld.get_out_file_name_base method
|
||||
else:
|
||||
_, _, slot_id, *_ = file.filename.split('.')[0].split('_', 3)
|
||||
try:
|
||||
_, _, slot_id, *_ = file.filename.split('.')[0].split('_', 3)
|
||||
except ValueError:
|
||||
flash("Error: Unexpected file found in .zip: " + file.filename)
|
||||
return
|
||||
data = zfile.open(file, "r").read()
|
||||
files[int(slot_id[1:])] = data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user