summaryrefslogtreecommitdiffstats
path: root/src/db/builds
diff options
context:
space:
mode:
authordev <dev@localhost>2026-11-20 17:26:52 +0000
committerdev <dev@localhost>2026-11-20 17:26:52 +0000
commit154f6f6dd284c11da82cf1188ff8549db6459228 (patch)
tree484edb3f9a77156df8dce7c2f3acaf443b014f89 /src/db/builds
parent8cd32e5309b14f5264813e5f2ce6ecdb5aa41fb4 (diff)
downloadaur-build-154f6f6dd284c11da82cf1188ff8549db6459228.tar.gz
aur-build-154f6f6dd284c11da82cf1188ff8549db6459228.zip
db: close what nothing reaches, and say what cannot be closed
db handed out 226 items and 36 of them were named by nobody at all — not by the crate, not by the tests. Making them private is the whole of this commit, but the interesting part is what the compiler said afterwards. Twenty-five closed cleanly. Eleven did not, and they are the ones worth writing down: AuditRow, NoticeRow, PackageRow, Subscription, StepRow, Unbuilt, OpenReview, ReviewSubject, Migration, Writer, predecessors. None is named outside db, yet none can be made private, because a public query returns them and callers bind them with `let` and call methods on them. They are load-bearing and invisible to a name search. So the census's `dead` count means "the name is never written outside the module", which is a lead rather than a verdict, and the census now says so: the way to find out which flagged items are real is to privatize them and let rustc answer. Those eleven are budgeted with that reason, not zeroed to make a number look good. Nineteen items turned out to be dead code rather than merely unexported — set_release, set_candidate, set_pkgbase, set_profile, set_kind, current_state, index_pkgbase_drift, wal_stats, call_for_tests, put_notice, is_ours, list_pkgbases, set_unpinable, artifact_id_by_digest_in, subscription_poll_interval, the four never-emitted notice kinds, and StateEnum::as_str, which the impl_state_enum macro was required to define for all five enums while nothing called it through the trait. Privatizing is what proved they were unused; leaving them private-but-present would have just hidden dead code behind a narrower address. Ten items became pub(crate): the Writer actor's call/tx/send surface, Readers, the StateEnum trait, json_or, predecessors, DEFAULT_SETTINGS. `Db.readers` was named nowhere outside db, so the field closed with the type. db: 226 pub / 36 dead-only -> 201 pub / 11 dead-only. 277 passed / 0 failed, clippy -D warnings clean, schema_ownership and architecture green.
Diffstat (limited to 'src/db/builds')
-rw-r--r--src/db/builds/mod.rs27
-rw-r--r--src/db/builds/steps.rs45
2 files changed, 6 insertions, 66 deletions
diff --git a/src/db/builds/mod.rs b/src/db/builds/mod.rs
index 2e116bb..2035cfd 100644
--- a/src/db/builds/mod.rs
+++ b/src/db/builds/mod.rs
@@ -286,27 +286,10 @@ pub fn cancel_requested(db: &Db, id: &str) -> Result<bool> {
// legal moves.
mod steps;
+
pub use steps::{
- StepRow,
- begin_step,
- blocked_builds,
- cancel_superseded,
- claim_batch,
- current_state,
- finish_step,
- in_flight,
- queue_depth,
- requeue_transient,
- retry,
- set_blocked_on,
- set_candidate,
- set_kind,
- set_pkgbase,
- set_profile,
- set_release,
- set_release_in,
- set_world,
- step_status,
- steps,
- touch,
+ begin_step, blocked_builds, cancel_superseded, claim_batch,
+ finish_step, in_flight, queue_depth, requeue_transient,
+ retry, set_blocked_on, set_release_in, set_world,
+ step_status, steps, touch,
};
diff --git a/src/db/builds/steps.rs b/src/db/builds/steps.rs
index 64d57c7..01d7c40 100644
--- a/src/db/builds/steps.rs
+++ b/src/db/builds/steps.rs
@@ -1,4 +1,4 @@
-use rusqlite::{params, Connection, OptionalExtension};
+use rusqlite::{params, OptionalExtension};
use super::transition_in_tx;
use crate::db::{BuildState, Db, StepState};
@@ -163,10 +163,6 @@ pub fn set_release_in(tx: &rusqlite::Transaction<'_>, id: &str, release_id: i64)
Ok(())
}
-pub fn set_release(db: &Db, id: &str, release_id: i64) -> Result<()> {
- let id = id.to_string();
- db.writer.tx(move |tx| set_release_in(tx, &id, release_id))
-}
pub fn set_world(db: &Db, id: &str, world_id: i64) -> Result<()> {
let id = id.to_string();
@@ -176,37 +172,9 @@ pub fn set_world(db: &Db, id: &str, world_id: i64) -> Result<()> {
})
}
-pub fn set_candidate(db: &Db, id: &str, candidate_id: i64) -> Result<()> {
- let id = id.to_string();
- db.writer.tx(move |tx| {
- tx.execute("UPDATE build SET candidate_id=?1 WHERE id=?2", params![candidate_id, id])?;
- Ok(())
- })
-}
-pub fn set_pkgbase(db: &Db, id: &str, pkgbase_id: i64) -> Result<()> {
- let id = id.to_string();
- db.writer.tx(move |tx| {
- tx.execute("UPDATE build SET pkgbase_id=?1 WHERE id=?2", params![pkgbase_id, id])?;
- Ok(())
- })
-}
-pub fn set_profile(db: &Db, id: &str, profile: &str) -> Result<()> {
- let (id, p) = (id.to_string(), profile.to_string());
- db.writer.tx(move |tx| {
- tx.execute("UPDATE build SET build_profile=?1 WHERE id=?2", params![p, id])?;
- Ok(())
- })
-}
-pub fn set_kind(db: &Db, id: &str, kind: &str) -> Result<()> {
- let (id, k) = (id.to_string(), kind.to_string());
- db.writer.tx(move |tx| {
- tx.execute("UPDATE build SET kind=?1 WHERE id=?2", params![k, id])?;
- Ok(())
- })
-}
pub fn set_blocked_on(db: &Db, id: &str, blocked_on: &[String]) -> Result<()> {
let id = id.to_string();
@@ -217,17 +185,6 @@ pub fn set_blocked_on(db: &Db, id: &str, blocked_on: &[String]) -> Result<()> {
})
}
-pub fn current_state(c: &Connection, id: &str) -> Result<Option<BuildState>> {
- let s: Option<String> = c
- .query_row("SELECT state FROM build WHERE id=?1", params![id], |r| r.get(0))
- .optional()?;
- match s {
- None => Ok(None),
- Some(text) => BuildState::parse(&text)
- .map(Some)
- .ok_or_else(|| Error::invalid(format!("build {id} has a state outside the state machine: {text:?}"))),
- }
-}
pub fn claim_batch(db: &Db, owner: &str, limit: usize, lease_secs: i64) -> Result<Vec<String>> {
if limit == 0 {