fix: webserver: catch and report exceptions from open and mkdir, too
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m49s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m49s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
@@ -235,10 +235,13 @@ async def audiofile_upload(request):
|
|||||||
if type_ == 'directory':
|
if type_ == 'directory':
|
||||||
if length != 0:
|
if length != 0:
|
||||||
return 'directory request may not have content', 400
|
return 'directory request may not have content', 400
|
||||||
os.mkdir(path)
|
|
||||||
return '', 204
|
|
||||||
with open(path, 'wb') as newfile:
|
|
||||||
try:
|
try:
|
||||||
|
os.mkdir(path)
|
||||||
|
except OSError as ex:
|
||||||
|
return f'error creating directory: {ex}', 500
|
||||||
|
return '', 204
|
||||||
|
try:
|
||||||
|
with open(path, 'wb') as newfile:
|
||||||
if length > Request.max_body_length:
|
if length > Request.max_body_length:
|
||||||
bytes_copied = await stream_to_file(request.stream, newfile, length)
|
bytes_copied = await stream_to_file(request.stream, newfile, length)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user