tftsr-devops_investigation/src-tauri/src/db
Shaun Arman 66de8f71cb
Some checks are pending
Test / rust-fmt-check (push) Waiting to run
Test / rust-clippy (push) Waiting to run
Test / rust-tests (push) Waiting to run
Test / frontend-typecheck (push) Waiting to run
Test / frontend-tests (push) Waiting to run
fix: set SQLCipher cipher_page_size BEFORE first database access
Previously cipher_page_size was set AFTER the verification SELECT,
making it a no-op (SQLCipher locks page size on first access). This
caused two bugs:

1. Databases were created with the default page size regardless of the
   setting, then flushed on close using misaligned 4KB mmap pages on
   16KB kernel → corrupted file → SQLITE_NOTADB on reopen.

2. Reopening an existing DB used default (potentially wrong) page size
   for the initial read → decryption failure.

Fix: batch all cipher settings (key, page_size, kdf_iter, algorithms)
into a single execute_batch call BEFORE the first SELECT. This ensures:
- New databases are created with 16KB pages (aligned to Asahi kernel)
- Existing 16KB-page databases are reopened with the correct page size
- Close/flush operations use properly aligned mmap → no corruption

Note: existing 4KB-page databases (from v0.1.0) remain incompatible
and must be deleted once on upgrade.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:25:43 -05:00
..
connection.rs fix: set SQLCipher cipher_page_size BEFORE first database access 2026-03-29 21:25:43 -05:00
migrations.rs feat: initial implementation of TFTSR IT Triage & RCA application 2026-03-14 22:36:25 -05:00
mod.rs feat: initial implementation of TFTSR IT Triage & RCA application 2026-03-14 22:36:25 -05:00
models.rs feat: initial implementation of TFTSR IT Triage & RCA application 2026-03-14 22:36:25 -05:00