From 17bcfee2242f5fe00923fdc61cec5a4f3c856719 Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 1 Aug 2023 18:43:14 +0300 Subject: [PATCH] [FL-3441] faploader: always create app dir, even if it doesn't have subdirs (#2901) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- lib/flipper_application/application_assets.c | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/flipper_application/application_assets.c b/lib/flipper_application/application_assets.c index 1262870d5..083c3ca19 100644 --- a/lib/flipper_application/application_assets.c +++ b/lib/flipper_application/application_assets.c @@ -157,14 +157,6 @@ static bool flipper_application_assets_process_dirs( FuriString* full_path = flipper_application_assets_alloc_app_full_path(app_name); do { - if(!storage_simply_mkdir(storage, APPS_ASSETS_PATH)) { - break; - } - - if(!storage_simply_mkdir(storage, furi_string_get_cstr(full_path))) { - break; - } - FuriString* dir_path = furi_string_alloc(); char* path = NULL; @@ -279,6 +271,8 @@ bool flipper_application_assets_load(File* file, const char* elf_path, size_t of FURI_LOG_D(TAG, "Loading assets for %s", furi_string_get_cstr(app_name)); + FuriString* full_path = flipper_application_assets_alloc_app_full_path(app_name); + do { if(!storage_file_seek(file, offset, true)) { break; @@ -319,13 +313,23 @@ bool flipper_application_assets_load(File* file, const char* elf_path, size_t of FURI_LOG_D(TAG, "Assets removed"); } + if(!storage_simply_mkdir(storage, APPS_ASSETS_PATH)) { + break; + } + + if(!storage_simply_mkdir(storage, furi_string_get_cstr(full_path))) { + break; + } + // process directories - if(!flipper_application_assets_process_dirs(storage, file, app_name, header.dirs_count)) { + if(header.dirs_count && + !flipper_application_assets_process_dirs(storage, file, app_name, header.dirs_count)) { break; } // process files - if(!flipper_application_assets_process_files(storage, file, app_name, header.files_count)) { + if(header.files_count && !flipper_application_assets_process_files( + storage, file, app_name, header.files_count)) { break; } @@ -353,6 +357,7 @@ bool flipper_application_assets_load(File* file, const char* elf_path, size_t of } furi_record_close(RECORD_STORAGE); + furi_string_free(full_path); furi_string_free(app_name); FURI_LOG_D(TAG, "Assets loading %s", result ? "success" : "failed");