Simpl-Resultat/src-tauri/Cargo.toml
le king fu 89ee648629 fix(db): run every statement on one connection of the plugin's pool (#543)
tauri-plugin-sql opens each database with Pool::connect, a sqlx pool of
up to ten connections, and sqlx gives a connection back to its pool
through a spawned task. Two statements sent back to back made the pool
open a second connection and serve both in turn, so a transaction of
withTransaction was split: its BEGIN and first write on one connection,
a later write on the other, which waited for the first one's write lock
and failed with "database is locked" (code 5) after 5 s. Adding a keyword
from the right-click menu (six statements) and creating a sub-category
hit it; the 14 withTransaction call sites were exposed.

Right after Database.load, inside the exclusive section that opens a
profile, loadUnlocked now calls use_single_connection_pool, a new Tauri
command (db_pool_commands.rs) that replaces the plugin's DbPool::Sqlite
in DbInstances by a pool of one connection, never recycled, opened with
the plugin pool's own connect options, then closes the plugin's pool.
getDb() and withTransaction find the connection only once the switch
succeeded; a failed switch writes a folder-free Journal line, closes the
plugin's pool and fails the opening.

sqlx 0.8.6 becomes a direct dependency with features the plugin already
enables: Cargo.lock only gains the edge, no package.

test: reproduces #543. The Rust tests replay, on a real sqlx pool opened
like the plugin's, the statements of a keyword on one then two checked
transactions (one split) and of a sub-category: code 5 on the plugin's
pool, green after the swap (6 of 6 red on a no-op swap). db.test.ts pins
the place of the switch and its failure path.

Fixes #543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 01:18:43 +00:00

90 lines
4 KiB
TOML

[package]
name = "simpl-result"
version = "0.18.0"
description = "Personal finance management app"
license = "GPL-3.0-only"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "simpl_result_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
tauri-plugin-sql = { version = "2", features = ["sqlite"] }
# The sqlx of tauri-plugin-sql, named directly to replace the plugin's pool by
# a pool of one connection (#543, ADR 0027, db_pool_commands.rs). Same version
# as the plugin's, and only features it already enables: no new crate.
sqlx = { version = "0.8.6", default-features = false, features = ["sqlite", "runtime-tokio"] }
tauri-plugin-dialog = "2"
# Built without its default `zip` feature (#455): that feature only pulls
# `zip` on Windows and `tar` on Linux to unpack archived update packages, and
# ours are never archives (`createUpdaterArtifacts: true` serves the NSIS
# `.exe`, the `.deb` and the `.rpm` as they are). Restore it only if
# `createUpdaterArtifacts` becomes "v1Compatible" (docs/qa-update-cycle.md).
tauri-plugin-updater = { version = "2", default-features = false, features = ["rustls-tls"] }
tauri-plugin-process = "2"
tauri-plugin-deep-link = "2"
tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
libsqlite3-sys = { version = "0.30", features = ["bundled"] }
rusqlite = { version = "0.32", features = ["bundled"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
encoding_rs = "0.8"
walkdir = "2"
aes-gcm = "0.10"
argon2 = "0.5"
subtle = "2"
rand = "0.8"
jsonwebtoken = "9"
machine-uid = "0.5"
reqwest = { version = "0.12", features = ["json"] }
# Date arithmetic for the Modified Dietz return calculator (Issue #142):
# we need day-precision diffs to weight cash flows W_i = (T - t_i) / T.
# `serde` feature lets `NaiveDate` cross the Tauri command boundary in JSON.
chrono = { version = "0.4", default-features = false, features = ["serde", "std"] }
tokio = { version = "1", features = ["macros"] }
hostname = "0.4"
urlencoding = "2"
base64 = "0.22"
# OAuth token storage in OS keychain (Credential Manager on Windows,
# Secret Service on Linux). We use sync-secret-service to get sync
# methods that are safe to call from async Tauri commands without
# tokio runtime entanglement. Requires libdbus-1-dev at build time
# on Linux (libdbus-1-3 is present on every desktop Linux at runtime).
keyring = { version = "3.6", default-features = false, features = ["sync-secret-service", "crypto-rust", "windows-native"] }
zeroize = "1"
hmac = "0.12"
[dev-dependencies]
# Used in license_commands.rs tests to sign test JWTs. We avoid the `pem`
# feature because the `LineEnding` re-export path varies between versions
# of pkcs8/spki; building the PKCS#8 DER manually is stable and trivial
# for Ed25519.
ed25519-dalek = { version = "2", features = ["pkcs8", "rand_core"] }
# HTTP mock server for balance_commands fetch_price tests (Issue #155).
mockito = "1.6"
# MockRuntime for the profile database folder test (#390). The `test`
# feature adds no crate (`test = []` in tauri's manifest).
tauri = { version = "2", features = ["test"] }
[features]
# Dev-only escape hatch: when enabled, the SR_DEV_EDITION env var forces the
# resolved edition (free|base|premium) so the three license tiers can be tested
# without real license files. MUST stay out of `default` and of any release
# feature set — gating this on debug_assertions instead would let a custom
# release build honor the env var and become a Premium backdoor (CWE-489).
# Usage: cargo test --features dev-override, or `tauri dev` with
# `-- --features dev-override`.
dev-override = []