desktop: Import and Export work offline; the menu toggle is reachable; errors say why
CI & Build / Build now, or wait for Android? (push) Successful in 4s
Android / Build, or is the channel already serving this? (push) Successful in 4s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 12s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Python tests (push) Successful in 13s
CI & Build / integration (push) Successful in 48s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 4m26s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m32s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 4m10s
Desktop (Tauri) / Update manifest (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Successful in 12m42s
CI & Build / Build now, or wait for Android? (push) Successful in 4s
Android / Build, or is the channel already serving this? (push) Successful in 4s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 12s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Python tests (push) Successful in 13s
CI & Build / integration (push) Successful in 48s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 4m26s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m32s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 4m10s
Desktop (Tauri) / Update manifest (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Successful in 12m42s
Export and Import were a link to the server and a reject("needs a server") on the
desktop. Both now run in the core with no server:
- core/src/local/portable.rs builds the same zip the server writes (notes.json,
a Markdown file per note, each attachment this device holds) and reads either
export marker or a Google Keep Takeout zip, with the server's decompression
budget and an all-or-nothing transaction. Export saves to Downloads (no new
plugin) and the sidebar says where; Import takes the archive as raw IPC bytes.
- core/testdata/portable.json pins the format for both copies: the server runs
its Keep and native readers against it (test_portable_fixture.py) and checks
its real export's keys (test_integration.py); the core runs the same cases.
- Found on the way: both importers skipped a Keep note that is only a photo as
"empty". It now imports, on the server and in the core.
- New dependency, approved: `zip` (deflate only) plus `flate2` on its pure-Rust
backend, both already in the lockfile.
The AppImage applications-menu toggle moves from Account, which the desktop
never shows, to the Sync page; the first-run prompt now says so.
errorMessage (#5236) replaces the hand-rolled `.error ?? …` / `.message ?? e`
reads at the remaining catch sites, so a desktop failure shows its real reason.
Task #5170.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ use serde_json::Value;
|
||||
use tauri::State;
|
||||
|
||||
use inkwell_core::local::models::*;
|
||||
use inkwell_core::local::portable::{self, ImportSummary};
|
||||
use inkwell_core::local::retention;
|
||||
use inkwell_core::local::store;
|
||||
use inkwell_core::local::Db;
|
||||
@@ -150,6 +151,60 @@ pub async fn notes_add_attachment(
|
||||
store::add_attachment(&conn, &blobs, note_id, &filename, mime, bytes)
|
||||
}
|
||||
|
||||
/// Write every note to a zip in the Downloads folder and return where it went.
|
||||
///
|
||||
/// The same archive the server's Export makes, built here so it works with no server.
|
||||
/// Downloads rather than a Save As dialog, which would need another plugin; the path
|
||||
/// comes back so the window can say exactly where the file is. Never overwrites: a
|
||||
/// second export the same day gets `-2`, `-3`, and so on.
|
||||
#[tauri::command]
|
||||
pub async fn notes_export(
|
||||
app: tauri::AppHandle,
|
||||
db: State<'_, Db>,
|
||||
blobs: State<'_, BlobStore>,
|
||||
) -> Result<String, String> {
|
||||
use tauri::Manager;
|
||||
let bytes = {
|
||||
let conn = db.0.lock().map_err(|e| e.to_string())?;
|
||||
portable::export_zip(&conn, &blobs)?
|
||||
};
|
||||
let dir = app
|
||||
.path()
|
||||
.download_dir()
|
||||
.or_else(|_| app.path().home_dir())
|
||||
.map_err(|e| format!("Couldn't find a folder to save to: {e}"))?;
|
||||
let path = unused_path(&dir, &portable::export_stem());
|
||||
std::fs::write(&path, bytes).map_err(|e| format!("Couldn't save {}: {e}", path.display()))?;
|
||||
Ok(path.display().to_string())
|
||||
}
|
||||
|
||||
/// `<stem>.zip`, or the first `<stem>-N.zip` that doesn't exist yet.
|
||||
fn unused_path(dir: &std::path::Path, stem: &str) -> std::path::PathBuf {
|
||||
let first = dir.join(format!("{stem}.zip"));
|
||||
if !first.exists() {
|
||||
return first;
|
||||
}
|
||||
(2..)
|
||||
.map(|n| dir.join(format!("{stem}-{n}.zip")))
|
||||
.find(|p| !p.exists())
|
||||
.unwrap_or(first)
|
||||
}
|
||||
|
||||
/// Import an Inkwell export or a Google Keep Takeout zip. The archive is the raw IPC
|
||||
/// body, as an attachment's bytes are. Additive: nothing already here is changed.
|
||||
#[tauri::command]
|
||||
pub async fn notes_import(
|
||||
request: tauri::ipc::Request<'_>,
|
||||
db: State<'_, Db>,
|
||||
blobs: State<'_, BlobStore>,
|
||||
) -> Result<ImportSummary, String> {
|
||||
let tauri::ipc::InvokeBody::Raw(bytes) = request.body() else {
|
||||
return Err("The file's contents didn't arrive.".to_string());
|
||||
};
|
||||
let conn = db.0.lock().map_err(|e| e.to_string())?;
|
||||
portable::import_zip(&conn, &blobs, bytes)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn notes_delete_attachment(
|
||||
id: String,
|
||||
|
||||
@@ -178,6 +178,8 @@ pub fn run() {
|
||||
commands::local::notes_update_item,
|
||||
commands::local::notes_delete_item,
|
||||
commands::local::notes_add_attachment,
|
||||
commands::local::notes_export,
|
||||
commands::local::notes_import,
|
||||
commands::local::notes_delete_attachment,
|
||||
commands::local::notes_delete_preview,
|
||||
commands::local::notes_reorder,
|
||||
|
||||
Reference in New Issue
Block a user