Satisfy rustfmt and clippy on the album and folder picker changes

rustfmt over the files the albums work touched, and the album merge's
incoming row as a named struct rather than an eight-field tuple, which
clippy's type_complexity refused.
This commit is contained in:
2026-09-26 14:13:54 -04:00
parent 1abb18d972
commit 9b580c3720
18 changed files with 487 additions and 303 deletions
+36 -18
View File
@@ -239,7 +239,19 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
}
crate::albums::ensure_tables(tx)?;
let rows: Vec<(String, String, Option<String>, i64, i64, i64, bool, MergeVerdict)> = {
/// One album as the remote has it, and what the verdict made of it.
struct IncomingAlbum {
uuid: String,
name: String,
server_path: Option<String>,
created: i64,
revision: i64,
modified: i64,
deleted: bool,
verdict: MergeVerdict,
}
let rows: Vec<IncomingAlbum> = {
let mut stmt = tx.prepare(
"SELECT r.uuid, r.name, r.server_path, r.created, r.revision, r.modified,
r.deleted, l.revision, l.modified
@@ -253,16 +265,16 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
let deleted: bool = r.get::<_, i64>(6)? != 0;
let local_rev: Option<i64> = r.get(7)?;
let local_mod: Option<i64> = r.get(8)?;
Ok((
r.get(0)?,
r.get(1)?,
r.get(2)?,
r.get(3)?,
Ok(IncomingAlbum {
uuid: r.get(0)?,
name: r.get(1)?,
server_path: r.get(2)?,
created: r.get(3)?,
revision,
modified,
deleted,
verdict(local_rev.zip(local_mod), (revision, modified), deleted),
))
verdict: verdict(local_rev.zip(local_mod), (revision, modified), deleted),
})
})?
.collect::<Result<Vec<_>, _>>()?;
rows
@@ -289,29 +301,35 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
"DELETE FROM main.album_folders
WHERE album_id = (SELECT id FROM main.albums WHERE uuid = ?1)",
)?;
for (uuid, name, server_path, created, revision, modified, deleted, v) in rows {
if v == MergeVerdict::KeptLocal {
for row in rows {
if row.verdict == MergeVerdict::KeptLocal {
report.albums_kept_local += 1;
continue;
}
take.execute(rusqlite::params![
uuid, name, server_path, created, revision, modified, deleted as i64
row.uuid,
row.name,
row.server_path,
row.created,
row.revision,
row.modified,
row.deleted as i64
])?;
if deleted {
forget.execute([&uuid])?;
unfold.execute([&uuid])?;
} else if server_path.is_some() {
if row.deleted {
forget.execute([&row.uuid])?;
unfold.execute([&row.uuid])?;
} else if row.server_path.is_some() {
// Another device moved the album to the server with the newer
// revision; a local folder chosen here is no longer where it
// goes.
unfold.execute([&uuid])?;
unfold.execute([&row.uuid])?;
}
report.albums_taken += 1;
}
}
report.album_exports_added =
tx.execute(ALBUM_EXPORTS_BY_FILE_ID, [])? + tx.execute(ALBUM_EXPORTS_BY_CONTENT_HASH, [])?;
report.album_exports_added = tx.execute(ALBUM_EXPORTS_BY_FILE_ID, [])?
+ tx.execute(ALBUM_EXPORTS_BY_CONTENT_HASH, [])?;
Ok(())
}