diff --git a/frontend/js/main.js b/frontend/js/main.js index 4bf6b21..fe42db0 100644 --- a/frontend/js/main.js +++ b/frontend/js/main.js @@ -96,7 +96,7 @@ async function init() { const result = await window.__TAURI__.core.invoke("import_seed_products"); if (unlisten) unlisten(); - } catch (e) { console.error("[SEED]", e); } + } catch (e) { console.error("[SEED]", e); document.getElementById("boot-label").textContent = "Seed: " + e; } // Apply safe area insets (Android status bar / nav bar) try { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 57b93a3..fdefe82 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -109,13 +109,18 @@ fn import_seed_products(app: tauri::AppHandle) -> Result { // tauri-plugin-sql may store DB in app_config_dir (desktop: ~/.config/...) // or app_data_dir (desktop: ~/.local/share/...). Check both. let config_dir = app.path().app_config_dir().unwrap_or_default(); + // tauri-plugin-sql stores DB in different locations depending on platform. + // Android: often in app root (/data/user/0/pkg/baldav.db), not in files/ subdir. let main_path = { let p_config = config_dir.join("baldav.db"); let p_data = data_dir.join("baldav.db"); let p_parent = data_dir.join("..").join("baldav.db"); + // Android app root: two levels up from app_data_dir (files/dev.baldav.app/) + let p_root = data_dir.join("..").join("..").join("baldav.db"); if p_config.exists() { p_config } else if p_data.exists() { p_data } else if p_parent.exists() { p_parent } + else if p_root.exists() { p_root } else { p_data } }; let main_db = rusqlite::Connection::open(&main_path).map_err(|e| e.to_string())?;