Skip to content

Commit

Permalink
Set path for zero-size files when writing
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Aug 9, 2022
1 parent d07e1df commit 78c5217
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions plugins/flipperproto0/storagerequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 78c5217

Please sign in to comment.