The store reads a note's body through note_body everywhere
should_snapshot and snapshot_revision each wrote out the SELECT that note_body already is. DRY pass #2, batch 2, F7 (#5372). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -561,9 +561,7 @@ const REVISION_WINDOW_MINUTES: i64 = 10;
|
|||||||
/// own — no "commit" the client has to declare, and no protocol surface to carry it,
|
/// own — no "commit" the client has to declare, and no protocol surface to carry it,
|
||||||
/// which matters because sync-apply takes this same path.
|
/// which matters because sync-apply takes this same path.
|
||||||
fn should_snapshot(conn: &Connection, id: &str, new_body: &str) -> rusqlite::Result<bool> {
|
fn should_snapshot(conn: &Connection, id: &str, new_body: &str) -> rusqlite::Result<bool> {
|
||||||
let current: String =
|
if note_body(conn, id)? == new_body {
|
||||||
conn.query_row("SELECT body FROM notes WHERE id = ?1", [id], |r| r.get(0))?;
|
|
||||||
if current == new_body {
|
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
// String comparison, not date maths: timestamps are RFC3339 UTC with a fixed
|
// String comparison, not date maths: timestamps are RFC3339 UTC with a fixed
|
||||||
@@ -578,8 +576,7 @@ fn should_snapshot(conn: &Connection, id: &str, new_body: &str) -> rusqlite::Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_revision(conn: &Connection, id: &str) -> rusqlite::Result<()> {
|
fn snapshot_revision(conn: &Connection, id: &str) -> rusqlite::Result<()> {
|
||||||
let body: String =
|
let body = note_body(conn, id)?;
|
||||||
conn.query_row("SELECT body FROM notes WHERE id = ?1", [id], |r| r.get(0))?;
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO note_revisions (id, note_id, body, created_at) VALUES (?1, ?2, ?3, ?4)",
|
"INSERT INTO note_revisions (id, note_id, body, created_at) VALUES (?1, ?2, ?3, ?4)",
|
||||||
params![new_id(), id, body, now()],
|
params![new_id(), id, body, now()],
|
||||||
|
|||||||
Reference in New Issue
Block a user