From 874eb46c93864fad91adb2b805da8bd486b5071c Mon Sep 17 00:00:00 2001 From: hedger Date: Thu, 11 Aug 2022 17:51:31 +0300 Subject: [PATCH] rpc: fixed missing read blocks (#1581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rpc: fixed missing read blocks * rpc: storage: restored old behavior * rpc: allocating 0 bytes for empty read Co-authored-by: あく --- applications/rpc/rpc_storage.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/applications/rpc/rpc_storage.c b/applications/rpc/rpc_storage.c index 468e1e08..ad6191b2 100644 --- a/applications/rpc/rpc_storage.c +++ b/applications/rpc/rpc_storage.c @@ -320,16 +320,21 @@ static void rpc_system_storage_read_process(const PB_Main* request, void* contex response->has_next = fs_operation_success && (size_left > 0); } else { - response->content.storage_read_response.has_file = false; + response->content.storage_read_response.file.data = + malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(0)); + response->content.storage_read_response.file.data->size = 0; + response->content.storage_read_response.has_file = true; response->has_next = false; fs_operation_success = true; } + + if(fs_operation_success) { + rpc_send_and_release(session, response); + } } while((size_left != 0) && fs_operation_success); } - if(fs_operation_success) { - rpc_send_and_release(session, response); - } else { + if(!fs_operation_success) { rpc_send_and_release_empty( session, request->command_id, rpc_system_storage_get_file_error(file)); }