Merge pull request #7286 from tannewt/fix_web_workflow_write

Fix writing files from web workflow
This commit is contained in:
Jeff Epler 2022-12-01 08:30:47 -06:00 committed by GitHub
commit 9c6c25ae57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -907,8 +907,13 @@ static void _write_file_and_reply(socketpool_socket_obj_t *socket, _request *req
error = true; error = true;
break; break;
} }
f_write(&active_file, bytes, len, NULL);
total_read += len; total_read += len;
UINT actual;
f_write(&active_file, bytes, len, &actual);
if (actual < (UINT)len) {
error = true;
break;
}
} }
f_close(&active_file); f_close(&active_file);
@ -917,7 +922,10 @@ static void _write_file_and_reply(socketpool_socket_obj_t *socket, _request *req
#endif #endif
override_fattime(0); override_fattime(0);
if (new_file) { if (error) {
_discard_incoming(socket, request->content_length - total_read);
_reply_server_error(socket, request);
} else if (new_file) {
_reply_created(socket, request); _reply_created(socket, request);
} else { } else {
_reply_no_content(socket, request); _reply_no_content(socket, request);