Skip to content

Commit

Permalink
Mass storage better image creation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Aug 3, 2023
1 parent f37f43a commit fe3c760
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
if(storage_file_open(
app->file, furi_string_get_cstr(app->file_path), FSAM_WRITE, FSOM_CREATE_NEW)) {
uint64_t size = app->create_image_size;
for(size_t i = app->create_size_unit + 2; i > 0; i--) size *= 1024;
for(size_t i = app->create_size_unit + 2; i > 0; i--) size *= 1000;
if(!storage_file_expand(app->file, size)) {
error = "Can't allocate data";
error = storage_file_get_error_desc(app->file);
storage_file_close(app->file);
storage_common_remove(app->fs_api, furi_string_get_cstr(app->file_path));
}
} else {
if(storage_file_exists(app->fs_api, furi_string_get_cstr(app->file_path))) {
error = "File already exists";
} else {
error = "Can't open file";
}
error = storage_file_get_error_desc(app->file);
}
storage_file_free(app->file);

if(default_name) strcpy(app->create_name, "");
mass_storage_app_show_loading_popup(app, false);

if(error) {
Expand All @@ -150,8 +150,6 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
popup_set_timeout(app->popup, 0);
popup_disable_timeout(app->popup);
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewPopup);

if(default_name) strcpy(app->create_name, "");
break;
}
default:
Expand Down

0 comments on commit fe3c760

Please sign in to comment.