From 4c39dcbe0c40c89f92df93d8b572799e39e603e1 Mon Sep 17 00:00:00 2001 From: Anna Prosvetova Date: Sun, 31 Jul 2022 01:14:16 +0200 Subject: [PATCH] =?UTF-8?q?=E2=98=A6=EF=B8=8F=20Rpc:=20fix=20backup=20comm?= =?UTF-8?q?ands=20responses=20(#1502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/rpc/rpc_storage.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/applications/rpc/rpc_storage.c b/applications/rpc/rpc_storage.c index 89c94b03..d2b43ff6 100644 --- a/applications/rpc/rpc_storage.c +++ b/applications/rpc/rpc_storage.c @@ -594,23 +594,19 @@ static void rpc_system_storage_backup_create_process(const PB_Main* request, voi FURI_LOG_D(TAG, "BackupCreate"); - RpcSession* session = (RpcSession*)context; + RpcStorageSystem* rpc_storage = context; + RpcSession* session = rpc_storage->session; furi_assert(session); - PB_Main* response = malloc(sizeof(PB_Main)); - response->command_id = request->command_id; - response->has_next = false; - Storage* fs_api = furi_record_open(RECORD_STORAGE); bool backup_ok = lfs_backup_create(fs_api, request->content.storage_backup_create_request.archive_path); - response->command_status = backup_ok ? PB_CommandStatus_OK : PB_CommandStatus_ERROR; furi_record_close(RECORD_STORAGE); - rpc_send_and_release(session, response); - free(response); + rpc_send_and_release_empty( + session, request->command_id, backup_ok ? PB_CommandStatus_OK : PB_CommandStatus_ERROR); } static void rpc_system_storage_backup_restore_process(const PB_Main* request, void* context) { @@ -619,24 +615,19 @@ static void rpc_system_storage_backup_restore_process(const PB_Main* request, vo FURI_LOG_D(TAG, "BackupRestore"); - RpcSession* session = (RpcSession*)context; + RpcStorageSystem* rpc_storage = context; + RpcSession* session = rpc_storage->session; furi_assert(session); - PB_Main* response = malloc(sizeof(PB_Main)); - response->command_id = request->command_id; - response->has_next = false; - response->command_status = PB_CommandStatus_OK; - Storage* fs_api = furi_record_open(RECORD_STORAGE); bool backup_ok = lfs_backup_unpack(fs_api, request->content.storage_backup_restore_request.archive_path); - response->command_status = backup_ok ? PB_CommandStatus_OK : PB_CommandStatus_ERROR; furi_record_close(RECORD_STORAGE); - rpc_send_and_release(session, response); - free(response); + rpc_send_and_release_empty( + session, request->command_id, backup_ok ? PB_CommandStatus_OK : PB_CommandStatus_ERROR); } void* rpc_system_storage_alloc(RpcSession* session) {