From 78c52175a8464c806d445582b4947f0db66f4294 Mon Sep 17 00:00:00 2001 From: Georgii Surkov Date: Tue, 9 Aug 2022 16:10:36 +0300 Subject: [PATCH] Set path for zero-size files when writing --- plugins/flipperproto0/storagerequest.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/flipperproto0/storagerequest.cpp b/plugins/flipperproto0/storagerequest.cpp index 318fadf8..5c581e6d 100644 --- a/plugins/flipperproto0/storagerequest.cpp +++ b/plugins/flipperproto0/storagerequest.cpp @@ -52,19 +52,16 @@ StorageReadRequest::StorageReadRequest(uint32_t id, const QByteArray &path): StorageWriteRequest::StorageWriteRequest(uint32_t id, const QByteArray &path, const QByteArray &data, bool hasNext): AbstractStorageRequest(id, PB_Main_storage_write_request_tag, path, hasNext) { - if(data.isEmpty()) { - return; - } - auto &content = m_message.content.storage_write_request; - content.has_file = true; + content.has_file = !data.isEmpty(); content.path = pathData(); - content.file.data = (pb_bytes_array_t*)malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data.size())); - content.file.data->size = data.size(); - - memcpy(content.file.data->bytes, data.data(), data.size()); + if(content.has_file) { + content.file.data = (pb_bytes_array_t*)malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data.size())); + content.file.data->size = data.size(); + memcpy(content.file.data->bytes, data.data(), data.size()); + } } StorageWriteRequest::~StorageWriteRequest()