desktop: rustfmt the push module
Seven hunks, applied verbatim from run 2903's cargo fmt --check diff. The reordered job already paid off: clippy and all 60 tests ran and passed in that same run, so this is known to be formatting only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SreJkbxB4gx8pPsu8QbLPi
This commit is contained in:
@@ -161,11 +161,7 @@ pub fn collect(conn: &Connection, limit: usize) -> rusqlite::Result<Vec<Change>>
|
|||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_deletes(
|
fn collect_deletes(conn: &Connection, out: &mut Vec<Change>, limit: usize) -> rusqlite::Result<()> {
|
||||||
conn: &Connection,
|
|
||||||
out: &mut Vec<Change>,
|
|
||||||
limit: usize,
|
|
||||||
) -> rusqlite::Result<()> {
|
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT entity, id, deleted_at FROM pending_deletes ORDER BY deleted_at LIMIT ?1",
|
"SELECT entity, id, deleted_at FROM pending_deletes ORDER BY deleted_at LIMIT ?1",
|
||||||
)?;
|
)?;
|
||||||
@@ -227,9 +223,8 @@ fn collect_labels(conn: &Connection, out: &mut Vec<Change>, limit: usize) -> rus
|
|||||||
fn collect_notes(conn: &Connection, out: &mut Vec<Change>, limit: usize) -> rusqlite::Result<()> {
|
fn collect_notes(conn: &Connection, out: &mut Vec<Change>, limit: usize) -> rusqlite::Result<()> {
|
||||||
let remaining = limit.saturating_sub(out.len());
|
let remaining = limit.saturating_sub(out.len());
|
||||||
let ids: Vec<String> = {
|
let ids: Vec<String> = {
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt =
|
||||||
"SELECT id FROM notes WHERE dirty = 1 ORDER BY updated_at LIMIT ?1",
|
conn.prepare("SELECT id FROM notes WHERE dirty = 1 ORDER BY updated_at LIMIT ?1")?;
|
||||||
)?;
|
|
||||||
let rows = stmt.query_map(params![remaining as i64], |r| r.get::<_, String>(0))?;
|
let rows = stmt.query_map(params![remaining as i64], |r| r.get::<_, String>(0))?;
|
||||||
rows.collect::<rusqlite::Result<Vec<String>>>()?
|
rows.collect::<rusqlite::Result<Vec<String>>>()?
|
||||||
};
|
};
|
||||||
@@ -301,9 +296,8 @@ fn note_change(conn: &Connection, id: &str) -> rusqlite::Result<Change> {
|
|||||||
// server from the body; sending them as label_ids would convert them into manual
|
// server from the body; sending them as label_ids would convert them into manual
|
||||||
// assignments that no longer disappear when the #tag is removed from the text.
|
// assignments that no longer disappear when the #tag is removed from the text.
|
||||||
let label_ids = {
|
let label_ids = {
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt =
|
||||||
"SELECT label_id FROM note_labels WHERE note_id = ?1 AND via_tag = 0",
|
conn.prepare("SELECT label_id FROM note_labels WHERE note_id = ?1 AND via_tag = 0")?;
|
||||||
)?;
|
|
||||||
let rows = stmt.query_map(params![id], |r| r.get::<_, String>(0))?;
|
let rows = stmt.query_map(params![id], |r| r.get::<_, String>(0))?;
|
||||||
rows.collect::<rusqlite::Result<Vec<String>>>()?
|
rows.collect::<rusqlite::Result<Vec<String>>>()?
|
||||||
};
|
};
|
||||||
@@ -391,8 +385,13 @@ pub fn apply_results(
|
|||||||
// retried, and surface the reason. A duplicate label name is the
|
// retried, and surface the reason. A duplicate label name is the
|
||||||
// realistic case and only a human can resolve it.
|
// realistic case and only a human can resolve it.
|
||||||
summary.rejected += 1;
|
summary.rejected += 1;
|
||||||
let reason = result.error.clone().unwrap_or_else(|| result.status.clone());
|
let reason = result
|
||||||
summary.errors.push(format!("{} {}: {reason}", change.entity, change.id));
|
.error
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| result.status.clone());
|
||||||
|
summary
|
||||||
|
.errors
|
||||||
|
.push(format!("{} {}: {reason}", change.entity, change.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,11 +412,7 @@ pub fn apply_results(
|
|||||||
Ok(summary)
|
Ok(summary)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_dirty(
|
fn clear_dirty(conn: &Connection, change: &Change, revision: Option<i64>) -> rusqlite::Result<()> {
|
||||||
conn: &Connection,
|
|
||||||
change: &Change,
|
|
||||||
revision: Option<i64>,
|
|
||||||
) -> rusqlite::Result<()> {
|
|
||||||
// A delete has no local row left to update.
|
// A delete has no local row left to update.
|
||||||
if change.op == "delete" {
|
if change.op == "delete" {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -560,8 +555,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dirty_count(conn: &Connection) -> i64 {
|
fn dirty_count(conn: &Connection) -> i64 {
|
||||||
conn.query_row("SELECT COUNT(*) FROM notes WHERE dirty = 1", [], |r| r.get(0))
|
conn.query_row("SELECT COUNT(*) FROM notes WHERE dirty = 1", [], |r| {
|
||||||
.expect("count")
|
r.get(0)
|
||||||
|
})
|
||||||
|
.expect("count")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -746,6 +743,9 @@ mod tests {
|
|||||||
let change = Change::delete("note", "n1".into(), "2026-07-26T00:00:00.000Z".into());
|
let change = Change::delete("note", "n1".into(), "2026-07-26T00:00:00.000Z".into());
|
||||||
let json = serde_json::to_string(&change).expect("serialize");
|
let json = serde_json::to_string(&change).expect("serialize");
|
||||||
assert!(json.contains("\"op\":\"delete\""), "got {json}");
|
assert!(json.contains("\"op\":\"delete\""), "got {json}");
|
||||||
assert!(!json.contains("body"), "a delete carries no content: {json}");
|
assert!(
|
||||||
|
!json.contains("body"),
|
||||||
|
"a delete carries no content: {json}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user