From ef839ba0cdbbd5bf3a14fba76e2ac8a9f0890f68 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 8 Oct 2026 14:17:26 -0400 Subject: [PATCH] The store's layout names live in the core: local::DB_FILE, BLOBS_DIR "inkwell.db" and "blobs" were spelled out in the ffi and the desktop (whose copy of DB_FILE sat in the crossover shim). The layout is the core's, the same on every client, so the names are now core constants and both clients read them. DRY pass #2, batch 1, F4 (#5372). Co-Authored-By: Claude Opus 5.5 --- android/ffi/src/lib.rs | 4 ++-- core/src/local/mod.rs | 6 ++++++ desktop/src-tauri/src/crossover.rs | 3 ++- desktop/src-tauri/src/lib.rs | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/android/ffi/src/lib.rs b/android/ffi/src/lib.rs index 97c364f..a7b5ab9 100644 --- a/android/ffi/src/lib.rs +++ b/android/ffi/src/lib.rs @@ -163,10 +163,10 @@ impl Inkwell { let dir = PathBuf::from(data_dir); std::fs::create_dir_all(&dir).map_err(CoreError::store)?; - let db = local::open(&dir.join("inkwell.db")).map_err(CoreError::store)?; + let db = local::open(&dir.join(local::DB_FILE)).map_err(CoreError::store)?; log::info!("local store ready — {}", local::summary(&db)); - let blobs = BlobStore::new(dir.join("blobs")).map_err(CoreError::store)?; + let blobs = BlobStore::new(dir.join(local::BLOBS_DIR)).map_err(CoreError::store)?; Ok(Arc::new(Inkwell { db, blobs, diff --git a/core/src/local/mod.rs b/core/src/local/mod.rs index bd1ce4e..47a9b4d 100644 --- a/core/src/local/mod.rs +++ b/core/src/local/mod.rs @@ -17,6 +17,12 @@ use std::sync::Mutex; use rusqlite::Connection; +/// The store's file inside a client's data directory. The layout is the same on +/// every client, so a store is readable by any client that opens it. +pub const DB_FILE: &str = "inkwell.db"; +/// Attachment bytes, filed by content hash, beside [`DB_FILE`]. +pub const BLOBS_DIR: &str = "blobs"; + /// The shared database handle. rusqlite connections aren't `Sync`, so a `Mutex` /// serializes access — fine, since operations are quick and a client is single-user. /// How it is held is the caller's business: Tauri manages it as state, Android holds diff --git a/desktop/src-tauri/src/crossover.rs b/desktop/src-tauri/src/crossover.rs index eab1eec..7fc330a 100644 --- a/desktop/src-tauri/src/crossover.rs +++ b/desktop/src-tauri/src/crossover.rs @@ -19,11 +19,12 @@ use std::fs; use std::io; use std::path::Path; +use inkwell_core::local::DB_FILE; + /// The identifier ThoughtSync shipped under. Its app-data dir is a sibling of ours. pub const LEGACY_IDENTIFIER: &str = "com.fabledsword.thoughtsync"; const LEGACY_DB: &str = "thoughtsync.db"; -pub const DB_FILE: &str = "inkwell.db"; /// What a crossover did, for the startup log. #[derive(Debug, PartialEq, Eq)] diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 49c0f49..5bfd698 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -126,7 +126,7 @@ pub fn run() { log_crossover(&legacy, crossover::adopt_legacy_data(&legacy, &dir)); } std::fs::create_dir_all(&dir)?; - let db_path = dir.join(crossover::DB_FILE); + let db_path = dir.join(local::DB_FILE); log::info!("opening local store: {}", db_path.display()); let db = local::open(&db_path)?; log::info!("local store ready — {}", local::summary(&db)); @@ -142,7 +142,7 @@ pub fn run() { app.manage(db); // Attachment bytes live beside the database, filed by content hash, so a // synced image is readable with no network (M10.7d). - let blobs = sync::blobs::BlobStore::new(dir.join("blobs"))?; + let blobs = sync::blobs::BlobStore::new(dir.join(local::BLOBS_DIR))?; log::info!("attachment store ready: {}", blobs.root().display()); // Hand the directory to the URI-scheme handler registered below, which // was built before this path could be resolved.