Workaround double load on boot of asset packs, settings...

This commit is contained in:
Willy-JL
2024-08-21 05:19:49 +02:00
parent 915b1c790d
commit af6d0731b3
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -60,7 +60,7 @@ Storage* storage_app_alloc(void) {
#include <furi/flipper.h>
#include <toolbox/run_parallel.h>
static int32_t sd_mount_handler(void* context) {
static int32_t sd_mount_callback(void* context) {
Storage* app = context;
StorageEvent event = {.type = StorageEventTypeCardMount};
@@ -108,7 +108,7 @@ void storage_tick(Storage* app) {
#ifndef FURI_RAM_EXEC
// Can't use pubsub for migration and can't lockup storage thread,
// see more explanation in flipper_mount_callback()
run_parallel(sd_mount_handler, app, 3 * 1024);
run_parallel(sd_mount_callback, app, 3 * 1024);
#else
StorageEvent event = {.type = StorageEventTypeCardMount};
furi_pubsub_publish(app->pubsub, &event);
+10
View File
@@ -123,11 +123,18 @@ void flipper_migrate_files() {
// service is deadlocked processing pubsub and cannot process file operations
// So instead storage runs this function in background thread and then
// dispatches the pubsub event to everyone else
bool skip_double_mount = false;
void flipper_mount_callback(const void* message, void* context) {
UNUSED(context);
const StorageEvent* event = message;
if(event->type == StorageEventTypeCardMount) {
// Workaround to avoid double load on boot but also have animated boot screen
if(skip_double_mount) {
skip_double_mount = false;
return;
}
// Migrate locations before other services load on SD insert
flipper_migrate_files();
@@ -180,6 +187,9 @@ void flipper_init(void) {
FURI_LOG_D(TAG, "SD Card not ready, skipping early init");
// Init on SD insert done by storage using flipper_mount_callback()
} else {
// Workaround to avoid double load on boot but also have animated boot screen
skip_double_mount = true;
canvas_draw_icon(canvas, 39, 43, &I_dir_10px);
canvas_commit(canvas);
flipper_migrate_files();