Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Prosvetova <anna@prosvetova.me>2022-07-31 02:14:16 +0300
committerGitHub <noreply@github.com>2022-07-31 02:14:16 +0300
commit4c39dcbe0c40c89f92df93d8b572799e39e603e1 (patch)
treedecf09cc98d24827365262a0c56203b2da19748d
parentc40e8811d68e9f4b8f603ae5d5826b814521014d (diff)
☦️ Rpc: fix backup commands responses (#1502)
-rw-r--r--applications/rpc/rpc_storage.c25
1 files 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) {