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 <59490463+black-sliver@users.noreply.github.com> --------- Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
This commit is contained in:
parent
d7475ddd73
commit
88dfbd4087
|
@ -104,13 +104,21 @@ def upload_zip_to_db(zfile: zipfile.ZipFile, owner=None, meta={"race": False}, s
|
||||||
|
|
||||||
# Factorio
|
# Factorio
|
||||||
elif file.filename.endswith(".zip"):
|
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()
|
data = zfile.open(file, "r").read()
|
||||||
files[int(slot_id[1:])] = data
|
files[int(slot_id[1:])] = data
|
||||||
|
|
||||||
# All other files using the standard MultiWorld.get_out_file_name_base method
|
# All other files using the standard MultiWorld.get_out_file_name_base method
|
||||||
else:
|
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()
|
data = zfile.open(file, "r").read()
|
||||||
files[int(slot_id[1:])] = data
|
files[int(slot_id[1:])] = data
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue