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

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
2026-01-27 19:11:47 +01:00
parent 0a20b70478
commit fa4d8debd0

View File

@@ -235,10 +235,13 @@ async def audiofile_upload(request):
if type_ == 'directory':
if length != 0:
return 'directory request may not have content', 400
os.mkdir(path)
return '', 204
with open(path, 'wb') as newfile:
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:
bytes_copied = await stream_to_file(request.stream, newfile, length)
else: