From cea14ae9c5843dcce3b4d36985811bd66bcb54a3 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 2 Oct 2022 06:23:09 +0300 Subject: [PATCH] fix dir creation bug, save files only for RAW TODO: files are broken when they have more than 512 elements in one line Split file to 512 element chunks as it done in regular Read RAW --- applications/main/subghz/subghz_history.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c index 154bfa8f2..cb8550ed9 100644 --- a/applications/main/subghz/subghz_history.c +++ b/applications/main/subghz/subghz_history.c @@ -93,7 +93,7 @@ bool subghz_history_clear_dir_or_create(SubGhzHistory* instance, bool only_remov // Uncomment it // Stage 2 - create dir - if(!only_remove_dir && res) { + if(!only_remove_dir) { res = storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR); #if FURI_DEBUG FURI_LOG_D(TAG, "storage_simply_mkdir done: %s", res ? "true" : "false"); @@ -189,9 +189,9 @@ void subghz_history_reset(SubGhzHistory* instance) { instance->last_index_write = 0; instance->code_last_hash_data = 0; - if(instance->write_tmp_files) { + /*if(instance->write_tmp_files) { instance->write_tmp_files = subghz_history_clear_dir_or_create(instance, false); - } + }*/ } uint16_t subghz_history_get_item(SubGhzHistory* instance) { @@ -329,6 +329,8 @@ bool subghz_history_add_to_history( string_init(item->item_str); string_init(item->protocol_name); + bool tmp_file_for_raw = false; + // At this point file mapped to memory otherwise file cannot decoded item->flipper_string = flipper_format_string_alloc(); subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset); @@ -357,6 +359,7 @@ bool subghz_history_add_to_history( if(!flipper_format_rewind(item->flipper_string)) { FURI_LOG_E(TAG, "Rewind error"); } + tmp_file_for_raw = true; break; } else if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) { @@ -414,7 +417,7 @@ bool subghz_history_add_to_history( // If we can write to files //bool no_close = false; - if(instance->write_tmp_files) { + if(instance->write_tmp_files && tmp_file_for_raw) { string_t filename; string_t dir_path; string_init(filename);