Fix dedup not running: Rust opened wrong DB path on Android
Root cause: app_data_dir() = files/dev.baldav.app/ but tauri-plugin-sql stores baldav.db in app root /data/user/0/pkg/baldav.db (two levels up). Rust created empty DB at wrong path, dedup ran on empty DB = no-op. Fix: added p_root = app_data_dir/../../../baldav.db check. Also: show seed error on boot label instead of swallowing silently.
This commit is contained in:
parent
a0c7dfb5e2
commit
9a4d62dd03
2 changed files with 6 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -109,13 +109,18 @@ fn import_seed_products(app: tauri::AppHandle) -> Result<String, String> {
|
|||
// 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())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue