Better virtual mount error handling --nobuild

This commit is contained in:
Willy-JL
2024-02-22 01:22:04 +00:00
parent 2001dd3920
commit 02c62beae9
2 changed files with 19 additions and 11 deletions

View File

@@ -109,7 +109,7 @@ static void js_usbdisk_create_image(struct mjs* mjs) {
Storage* storage = furi_record_open(RECORD_STORAGE); Storage* storage = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(storage); File* file = storage_file_alloc(storage);
do { do {
if(!storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_NEW)) { if(!storage_file_open(file, path, FSAM_READ | FSAM_WRITE, FSOM_CREATE_NEW)) {
error = storage_file_get_error_desc(file); error = storage_file_get_error_desc(file);
break; break;
} }
@@ -120,10 +120,14 @@ static void js_usbdisk_create_image(struct mjs* mjs) {
} }
error = "Image formatting failed"; error = "Image formatting failed";
if(storage_virtual_init(storage, file) != FSE_OK) break; if(storage_virtual_init(storage, file) != FSE_OK) {
if(storage_virtual_format(storage) != FSE_OK) break; if(storage_virtual_quit(storage) != FSE_OK) break;
if(storage_virtual_quit(storage) != FSE_OK) break; if(storage_virtual_init(storage, file) != FSE_OK) break;
error = NULL; }
if(storage_virtual_format(storage) == FSE_OK) {
error = NULL;
}
storage_virtual_quit(storage);
} while(0); } while(0);
storage_file_free(file); storage_file_free(file);
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);

View File

@@ -131,7 +131,7 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
if(!storage_file_open( if(!storage_file_open(
app->file, app->file,
furi_string_get_cstr(app->file_path), furi_string_get_cstr(app->file_path),
FSAM_WRITE, FSAM_READ | FSAM_WRITE,
FSOM_CREATE_NEW)) FSOM_CREATE_NEW))
break; break;
@@ -140,11 +140,15 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
if(!storage_file_expand(app->file, size)) break; if(!storage_file_expand(app->file, size)) break;
// Format as exFAT // Format as exFAT
if(storage_virtual_init(app->fs_api, app->file) != FSE_OK) break; error = "Image formatting failed";
if(storage_virtual_format(app->fs_api) != FSE_OK) break; if(storage_virtual_init(app->fs_api, app->file) != FSE_OK) {
if(storage_virtual_quit(app->fs_api) != FSE_OK) break; if(storage_virtual_quit(app->fs_api) != FSE_OK) break;
if(storage_virtual_init(app->fs_api, app->file) != FSE_OK) break;
success = true; }
if(storage_virtual_format(app->fs_api) == FSE_OK) {
success = true;
}
storage_virtual_quit(app->fs_api);
} while(false); } while(false);
if(!success) { if(!success) {