Every lock of the store goes through Db::conn

Db::conn is documented as the one way to take the lock, yet five production and
test sites reached past it with db.0.lock(): the startup summary, the desktop's
trash sweep and config_get, and tests in sharing and update. All five now call
conn().

DRY pass #2, batch 2, F8 (#5372).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 14:23:07 -04:00
co-authored by Claude Opus 5.5
parent 63dd206b91
commit ee771e3734
5 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ pub fn open_in_memory() -> rusqlite::Result<Db> {
/// A one-line count summary of the store, for the startup log.
pub fn summary(db: &Db) -> String {
let conn = match db.0.lock() {
let conn = match db.conn() {
Ok(c) => c,
Err(_) => return "counts unavailable (lock poisoned)".to_string(),
};
+2 -2
View File
@@ -105,7 +105,7 @@ mod tests {
fn the_shared_flag_follows_the_servers_answer_without_dirtying_the_note() {
let db = db();
{
let conn = db.0.lock().unwrap();
let conn = db.conn().unwrap();
conn.execute(
"INSERT INTO notes (id, body, created_at, updated_at, dirty)
VALUES ('n1', 'x', '2026-01-01', '2026-01-01', 0)",
@@ -125,7 +125,7 @@ mod tests {
created_at: None,
};
let read = |db: &Db| -> (bool, i64) {
let conn = db.0.lock().unwrap();
let conn = db.conn().unwrap();
conn.query_row("SELECT shared, dirty FROM notes WHERE id = 'n1'", [], |r| {
Ok((r.get(0)?, r.get(1)?))
})