diff options
Diffstat (limited to 'src/db/queries.rs')
| -rw-r--r-- | src/db/queries.rs | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/src/db/queries.rs b/src/db/queries.rs index 924051d..583676b 100644 --- a/src/db/queries.rs +++ b/src/db/queries.rs @@ -6,10 +6,6 @@ use crate::time; // ---------------------------------------------------------------- settings -- -/// Every setting, for the settings page. -/// -/// Row-error policy, applied everywhere in `db` (m-9): a row that cannot be read -/// fails the query rather than being dropped silently. pub fn all_settings(db: &Db) -> Result<Vec<(String, String)>> { db.read(|c| { let mut st = c.prepare("SELECT key, value FROM settings ORDER BY key")?; @@ -26,13 +22,6 @@ pub fn setting(db: &Db, key: &str) -> Result<Option<String>> { }) } -/// An integer setting, or `default`. -/// -/// The policy, stated once (m-9): a *missing* setting is normal — the default is -/// the answer. A setting present but unparseable, or a read that failed, is not, -/// and silently returning the default would hide an operator's typo. Both still -/// fall back, because refusing to start over a tuning knob is worse — but they -/// fall back out loud. pub fn setting_i64(db: &Db, key: &str, default: i64) -> i64 { match setting(db, key) { Ok(None) => default, @@ -62,7 +51,6 @@ pub fn set_setting(writer: &Writer, key: &str, value: &str) -> Result<()> { // ------------------------------------------------------------------- audit -- -/// Append an audit row (I10). Every state transition funnels through here. pub fn audit( writer: &Writer, actor_kind: &str, @@ -94,9 +82,6 @@ pub fn audit( }) } -/// An audit row to append inside someone else's transaction. Build one with -/// [`AuditEntry::human`] or [`AuditEntry::system`]: `actor_kind` is a closed set -/// and the timestamp is not the caller's to improvise (§6 m-4). #[derive(Debug)] pub struct AuditEntry<'a> { pub at: &'a str, @@ -109,7 +94,6 @@ pub struct AuditEntry<'a> { } impl<'a> AuditEntry<'a> { - /// A decision a named human made (§11: every approval is attributable). pub fn human( at: &'a str, actor: &'a str, @@ -121,7 +105,6 @@ impl<'a> AuditEntry<'a> { Self { at, actor_kind: "human", actor, action, entity, entity_id, detail } } - /// Something the server did by itself: a publish, a requeue, a watcher tick. pub fn system( at: &'a str, action: &'a str, @@ -133,8 +116,6 @@ impl<'a> AuditEntry<'a> { } } -/// Append an audit row inside a caller's transaction (I10), so the record of a -/// decision commits with the decision or not at all. pub fn audit_in(tx: &rusqlite::Transaction<'_>, e: &AuditEntry<'_>) -> Result<()> { tx.execute( "INSERT INTO audit (at, actor_kind, actor, action, entity, entity_id, detail_json) @@ -150,7 +131,6 @@ pub fn audit_system(writer: &Writer, action: &str, entity: &str, entity_id: &str // -------------------------------------------------------------------- repo -- -/// Ensure the single repo row exists (decision 4: exactly one). pub fn ensure_repo(writer: &Writer, name: &str, path: &str, arch: &str, key: &str) -> Result<i64> { let (n, p, a, k) = (name.to_string(), path.to_string(), arch.to_string(), key.to_string()); writer.tx(move |tx| { @@ -229,7 +209,6 @@ pub fn get_subscription(db: &Db, pkgbase: &str) -> Result<Option<Subscription>> }) } -/// Subscribe: creates the pkgbase row and an active subscription. Idempotent. pub fn subscribe(writer: &Writer, repo_id: i64, pkgbase: &str, aur_url: &str) -> Result<i64> { let (p, u) = (pkgbase.to_string(), aur_url.to_string()); let at = time::now(); @@ -274,7 +253,6 @@ pub fn note_check(writer: &Writer, pkgbase: &str, next_check_at: &str, err: Opti }) } -/// Subscriptions whose next check is due. pub fn due_subscriptions(db: &Db, now: &str) -> Result<Vec<Subscription>> { db.read(|c| { let mut stmt = c.prepare(&format!( @@ -378,8 +356,6 @@ pub fn set_unpinable(writer: &Writer, pkgbase_id: i64, unpinable: bool) -> Resul }) } -/// Compare-and-swap the accepted-release pointer (§16: concurrent approvals). -/// Returns Ok(true) when the swap happened. pub fn cas_accepted_release( writer: &Writer, pkgbase_id: i64, @@ -398,7 +374,6 @@ pub fn cas_accepted_release( // ---------------------------------------------------------------- snapshot -- -/// Insert-or-get a snapshot for (pkgbase, aur_commit). #[allow(clippy::too_many_arguments)] pub fn put_snapshot( writer: &Writer, @@ -509,12 +484,6 @@ const RELEASE_COLS_R: &str = "r.id, r.pkgbase_id, r.candidate_id, r.approval_id, r.recipe_hash, r.upstream_pins_json, r.source_digests_json, r.epoch, r.pkgver, r.pkgrel, \ r.world_snapshot_id, r.state, r.published_at"; -/// Take a release out of the served index (§9, decision 23), in the caller's -/// transaction so the removal and the audit row explaining it are one fact. -/// -/// Refuses a release that is not currently published (m-10): re-withdrawing used -/// to report success and rewrite nothing. The write is a compare-and-swap on -/// `state='published'`, and the refusal names the state that was actually there. pub fn withdraw_release_in(tx: &rusqlite::Transaction<'_>, release_id: i64) -> Result<()> { let n = tx.execute( "UPDATE release SET state='withdrawn' WHERE id=?1 AND state='published'", @@ -551,8 +520,6 @@ pub fn release_by_id(db: &Db, id: i64) -> Result<Option<ReleaseRow>> { }) } -/// The accepted release of a pkgbase, by name. `None` for a pkgbase that has -/// never been accepted — the case that makes `first_introduction` special (§7.1b). pub fn accepted_release(db: &Db, pkgbase: &str) -> Result<Option<ReleaseRow>> { db.read(|c| { c.query_row( @@ -609,7 +576,6 @@ pub struct PackageRow { pub version: String, pub artifact_id: Option<i64>, pub pkgbase: String, - /// Bytes of the packaged .pkg.tar.zst, so the index page can show a size. pub size: Option<i64>, pub published_at: Option<String>, } @@ -647,7 +613,6 @@ pub fn index_packages(db: &Db) -> Result<Vec<PackageRow>> { }) } -/// Version of the package with this name currently in our index, if any. pub fn index_version(db: &Db, name: &str) -> Result<Option<String>> { db.read(|c| { c.query_row( @@ -661,9 +626,6 @@ pub fn index_version(db: &Db, name: &str) -> Result<Option<String>> { }) } -/// The exact artifact we serve for a package name: `(version, digest)`. This is -/// what a build's lease manifest pins — the dependency arrives as these bytes or -/// the build fails closed (§8). pub fn index_artifact(db: &Db, name: &str) -> Result<Option<(String, String)>> { db.read(|c| { c.query_row( @@ -678,8 +640,6 @@ pub fn index_artifact(db: &Db, name: &str) -> Result<Option<(String, String)>> { }) } -/// Is `name` one of the packages we publish? Used to filter world snapshots -/// down to our own packages (§10.1). pub fn is_ours(db: &Db, name: &str) -> Result<bool> { db.read(|c| { c.query_row( @@ -693,7 +653,6 @@ pub fn is_ours(db: &Db, name: &str) -> Result<bool> { }) } -/// All package names we publish (in_index), as a set. pub fn our_package_names(db: &Db) -> Result<std::collections::BTreeSet<String>> { db.read(|c| { let mut stmt = c.prepare("SELECT DISTINCT name FROM package WHERE state='in_index'")?; @@ -706,9 +665,6 @@ pub fn our_package_names(db: &Db) -> Result<std::collections::BTreeSet<String>> }) } -/// The recipe the accepted release was actually built from, by walking -/// release -> candidate -> snapshot. Risk scoring compares against this, which -/// is why "last seen" can never leak into a review (§6, I2). pub fn accepted_recipe(db: &Db, release: &ReleaseRow) -> Result<Option<Recipe>> { let cid = match release.candidate_id { Some(c) => c, @@ -728,7 +684,6 @@ pub fn accepted_recipe(db: &Db, release: &ReleaseRow) -> Result<Option<Recipe>> }) } -/// Recent builds for one pkgbase, newest first. pub fn builds_for_pkgbase(db: &Db, pkgbase_id: i64, limit: i64) -> Result<Vec<crate::db::builds::BuildRow>> { db.read(move |c| { let mut st = c.prepare( @@ -738,18 +693,12 @@ pub fn builds_for_pkgbase(db: &Db, pkgbase_id: i64, limit: i64) -> Result<Vec<cr FROM build WHERE pkgbase_id=?1 ORDER BY rowid DESC LIMIT ?2", )?; let rows = st.query_map(params![pkgbase_id, limit], crate::db::builds::row_to_build)?; - // A row we cannot read is an error, not a build that quietly disappears - // from the package page. rows.collect::<::rusqlite::Result<Vec<_>>>().map_err(Into::into) }) } // ------------------------------------------------------------ publish writes -- -// -// Publishing is the one externally visible step, so every statement it needs is -// here and the *decision* stays in `pipeline::publish` (I4). -/// The on-disk path of an artifact, by id. pub fn artifact_path(db: &Db, id: i64) -> Result<Option<String>> { db.read(|c| { Ok(c.query_row("SELECT path FROM artifact WHERE id=?1", params![id], |r| r.get::<_, String>(0)) @@ -757,15 +706,12 @@ pub fn artifact_path(db: &Db, id: i64) -> Result<Option<String>> { }) } -/// The artifact row for a content digest, if one exists. Two releases built from -/// identical bytes share one artifact row — that is the point of the digest. pub fn artifact_id_by_digest_in(tx: &rusqlite::Transaction<'_>, digest: &str) -> Result<Option<i64>> { Ok(tx .query_row("SELECT id FROM artifact WHERE digest=?1", params![digest], |r| r.get::<_, i64>(0)) .optional()?) } -/// The pkgbase's accepted pointer, read inside a transaction: the CAS baseline. pub fn accepted_pointer_in(tx: &rusqlite::Transaction<'_>, pkgbase_id: i64) -> Result<Option<i64>> { tx.query_row( "SELECT current_accepted_release_id FROM pkgbase WHERE id=?1", @@ -777,8 +723,6 @@ pub fn accepted_pointer_in(tx: &rusqlite::Transaction<'_>, pkgbase_id: i64) -> R .map_err(Into::into) } -/// Compare-and-swap the accepted pointer inside a transaction. `false` means it -/// was not where the caller thought it was, and the publish must not land. pub fn cas_accepted_release_in( tx: &rusqlite::Transaction<'_>, pkgbase_id: i64, @@ -792,8 +736,6 @@ pub fn cas_accepted_release_in( Ok(moved == 1) } -/// Retire whatever the index held for these names. The index holds exactly the -/// accepted pointers, so this runs before the new rows go in. pub fn remove_index_packages_in(tx: &rusqlite::Transaction<'_>, names: &[String]) -> Result<()> { if names.is_empty() { return Ok(()); @@ -805,7 +747,6 @@ pub fn remove_index_packages_in(tx: &rusqlite::Transaction<'_>, names: &[String] Ok(()) } -/// Retire one named package from the index (the §9 withdrawal path). pub fn remove_package_by_name_in(tx: &rusqlite::Transaction<'_>, repo_id: i64, name: &str) -> Result<()> { tx.execute( "UPDATE package SET state='removed' WHERE repo_id=?1 AND name=?2", @@ -814,8 +755,6 @@ pub fn remove_package_by_name_in(tx: &rusqlite::Transaction<'_>, repo_id: i64, n Ok(()) } -/// Everything a published release records. Borrowed because the caller is in the -/// middle of a transaction and has the values on the stack. pub struct NewRelease<'a> { pub pkgbase_id: i64, pub candidate_id: Option<i64>, @@ -831,7 +770,6 @@ pub struct NewRelease<'a> { pub build_id: &'a str, } -/// Insert the release row and return its id. pub fn insert_release_in(tx: &mut rusqlite::Transaction<'_>, r: &NewRelease<'_>, at: &str) -> Result<i64> { tx.execute( "INSERT INTO release (pkgbase_id, candidate_id, approval_id, aur_commit, recipe_hash, @@ -857,7 +795,6 @@ pub fn insert_release_in(tx: &mut rusqlite::Transaction<'_>, r: &NewRelease<'_>, Ok(tx.last_insert_rowid()) } -/// Put one package into the index, pointing at the artifact with this digest. pub fn insert_package_in( tx: &rusqlite::Transaction<'_>, repo_id: i64, @@ -877,12 +814,7 @@ pub fn insert_package_in( } // ------------------------------------------------------------ staleness reads -- -// -// Staleness is derived on read (§10.2). These return plain tuples: the *meaning* -// is `watch::staleness`'s business, the SQL is this module's. -/// `(pkgbase, world members JSON)` for every published release, taken from the -/// world snapshot its build recorded (§10.1). pub fn published_world_members(db: &Db) -> Result<Vec<(String, String)>> { db.read(|c| { let mut st = c.prepare( @@ -898,8 +830,6 @@ pub fn published_world_members(db: &Db) -> Result<Vec<(String, String)>> { }) } -/// `(pkgbase, served pkgver, newest candidate pkgver)` for every accepted -/// release — the pair the downgrade check compares (§10.2). pub fn served_vs_offered_pkgvers(db: &Db) -> Result<Vec<(String, String, String)>> { db.read(|c| { let mut st = c.prepare( @@ -922,12 +852,6 @@ pub fn served_vs_offered_pkgvers(db: &Db) -> Result<Vec<(String, String, String) }) } -/// Every in-index package's recipe JSON, as (name, srcinfo_json) — what each -/// dependency list actually said. -/// -/// One query, not one per package (m-17): `watch::staleness::dependents_of` -/// wants the whole table, and asking per name was an N+1 on a path that runs -/// after every publish. pub fn index_recipes(db: &Db) -> Result<Vec<(String, String)>> { db.read(|c| { let mut stmt = c.prepare( @@ -946,7 +870,6 @@ pub fn index_recipes(db: &Db) -> Result<Vec<(String, String)>> { }) } -/// The note a reviewer left on an approval, empty when there was none. pub fn approval_note(db: &Db, approval_id: i64) -> Result<String> { db.read(|c| { c.query_row("SELECT COALESCE(note,'') FROM approval WHERE id=?1", params![approval_id], |r| r.get::<_, String>(0)) @@ -956,7 +879,6 @@ pub fn approval_note(db: &Db, approval_id: i64) -> Result<String> { }) } -/// The snapshot a candidate was created from, for rendering its diff. pub fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Result<Option<i64>> { db.read(|c| { Ok(c.query_row("SELECT snapshot_id FROM candidate WHERE id=?1", params![candidate_id], |r| r.get::<_, i64>(0)) @@ -964,8 +886,6 @@ pub fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Result<Option<i64>> }) } -/// The poll interval configured for a subscription, as the scheduler already -/// knows it (§5.1: one place decides how often a pkgbase is checked). pub fn subscription_poll_interval(db: &Db, pkgbase: &str) -> Result<Option<i64>> { db.read(|c| { Ok(c.query_row( @@ -978,7 +898,6 @@ pub fn subscription_poll_interval(db: &Db, pkgbase: &str) -> Result<Option<i64>> }) } -/// Record a fetched source in the content-addressed cache (§5.3). pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, path: &str) -> Result<()> { let (u, d, p) = (url.to_string(), digest.to_string(), path.to_string()); let at = time::now(); @@ -992,7 +911,6 @@ pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, pat }) } -/// Where a cached source with this url+digest lives on disk. pub fn source_cache_path(db: &Db, url: &str, digest: &str) -> Result<Option<String>> { db.read(|c| { Ok(c.query_row( @@ -1004,7 +922,6 @@ pub fn source_cache_path(db: &Db, url: &str, digest: &str) -> Result<Option<Stri }) } -/// An artifact produced by a build, ready to record. pub struct NewArtifact<'a> { pub digest: &'a str, pub size: i64, @@ -1015,9 +932,6 @@ pub struct NewArtifact<'a> { pub at: &'a str, } -/// Record an artifact produced by a build. Identical bytes are one row: the -/// digest is the identity, and the row is re-stamped with the build that most -/// recently produced them. pub fn insert_artifact_in(tx: &rusqlite::Transaction<'_>, a: &NewArtifact<'_>) -> Result<()> { tx.execute( "INSERT INTO artifact (digest, size, path, signature_path, build_log_path, build_id, created_at) @@ -1030,7 +944,6 @@ pub fn insert_artifact_in(tx: &rusqlite::Transaction<'_>, a: &NewArtifact<'_>) - // --------------------------------------------------------- stage B cache -- -/// Exact cache hit: same recipe, same upstream tips (§5.2). pub fn stage_b_cache_get(db: &Db, pkgbase_id: i64, recipe_hash: &str, tip_hash: &str) -> Result<Option<StageBCacheRow>> { let (rh, th) = (recipe_hash.to_string(), tip_hash.to_string()); db.read(move |c| { @@ -1058,7 +971,6 @@ pub fn stage_b_cache_get(db: &Db, pkgbase_id: i64, recipe_hash: &str, tip_hash: }) } -/// The most recent answer for this pkgbase, if it is inside the cooldown window. pub fn stage_b_recent(db: &Db, pkgbase_id: i64, cooldown_secs: i64) -> Result<Option<StageBCacheRow>> { let cutoff = crate::time::secs_ago(cooldown_secs); db.read(move |c| { @@ -1132,8 +1044,6 @@ pub fn put_notice( }) } -/// Suppress a notice if an identical unacknowledged one already exists, so a -/// watcher polling daily does not spam the same alert. pub fn put_notice_once( writer: &Writer, pkgbase_id: i64, @@ -1290,11 +1200,7 @@ pub fn list_audit(db: &Db, limit: i64) -> Result<Vec<AuditRow>> { } // -------------------------------------------------------------- metrics reads -- -// -// The metrics surface is derived from live state, never stored (§10.3). -/// The `count(*)` idiom in one place, so a metric cannot accidentally become a -/// `count(*)` of a join. fn count_rows(db: &Db, sql: &str) -> Result<i64> { let sql = sql.to_string(); db.read(move |c| { @@ -1303,7 +1209,6 @@ fn count_rows(db: &Db, sql: &str) -> Result<i64> { }) } -/// `(state, count)` for every build state present. pub fn build_state_counts(db: &Db) -> Result<Vec<(String, i64)>> { db.read(|c| { let mut st = c.prepare("SELECT state, count(*) FROM build GROUP BY state ORDER BY state")?; @@ -1316,7 +1221,6 @@ pub fn build_state_counts(db: &Db) -> Result<Vec<(String, i64)>> { }) } -/// Seconds the oldest queued build has been waiting; 0 when the queue is empty. pub fn oldest_queued_age_secs(db: &Db, now: &str) -> Result<i64> { db.read(|c| { c.query_row( @@ -1330,12 +1234,10 @@ pub fn oldest_queued_age_secs(db: &Db, now: &str) -> Result<i64> { }) } -/// How many candidates are waiting for a decision. pub fn count_pending_reviews(db: &Db) -> Result<i64> { count_rows(db, "SELECT count(*) FROM candidate WHERE state='pending_review'") } -/// Age in seconds of every pending review; the caller sorts them. pub fn pending_review_ages_secs(db: &Db, now: &str) -> Result<Vec<i64>> { db.read(|c| { let mut st = c.prepare("SELECT julianday(?1) - julianday(detected_at) FROM candidate WHERE state='pending_review'")?; @@ -1364,7 +1266,6 @@ pub fn count_unacknowledged_notices(db: &Db) -> Result<i64> { count_rows(db, "SELECT count(*) FROM notice WHERE acknowledged_at IS NULL") } -/// Bytes of artifact still on disk. Purged rows are history, not usage. pub fn artifact_bytes_served(db: &Db) -> Result<u64> { db.read(|c| { c.query_row( @@ -1377,7 +1278,6 @@ pub fn artifact_bytes_served(db: &Db) -> Result<u64> { }) } -/// Seconds since the last retention run, if there has been one. pub fn last_gc_age_secs(db: &Db, now: &str) -> Result<Option<i64>> { let at = db.read(|c| { c.query_row("SELECT max(ran_at) FROM gc_run", [], |r| r.get::<_, Option<String>>(0)) @@ -1386,8 +1286,6 @@ pub fn last_gc_age_secs(db: &Db, now: &str) -> Result<Option<i64>> { Ok(at.and_then(|t| time::delta_secs(now, &t))) } -/// Seconds since the last successful poll of any source. This is the metric that -/// catches a watcher that stopped. pub fn last_poll_age_secs(db: &Db, now: &str) -> Result<Option<i64>> { let at = db.read(|c| { c.query_row("SELECT max(last_checked_at) FROM subscription", [], |r| r.get::<_, Option<String>>(0)) @@ -1398,7 +1296,6 @@ pub fn last_poll_age_secs(db: &Db, now: &str) -> Result<Option<i64>> { // -------------------------------------------------------------- retention reads -- -/// `(pkgbase id, current accepted release)` for every pkgbase, in id order. pub fn pkgbase_release_pointers(db: &Db) -> Result<Vec<(i64, Option<i64>)>> { db.read(|c| { let mut st = c.prepare("SELECT id, current_accepted_release_id FROM pkgbase ORDER BY id")?; @@ -1411,7 +1308,6 @@ pub fn pkgbase_release_pointers(db: &Db) -> Result<Vec<(i64, Option<i64>)>> { }) } -/// Published release ids of one pkgbase, newest first. pub fn published_release_ids(db: &Db, pkgbase_id: i64) -> Result<Vec<i64>> { db.read(|c| { let mut st = c.prepare("SELECT id FROM release WHERE pkgbase_id=?1 AND state='published' ORDER BY id DESC")?; @@ -1424,8 +1320,6 @@ pub fn published_release_ids(db: &Db, pkgbase_id: i64) -> Result<Vec<i64>> { }) } -/// Releases of one pkgbase that still back an `in_index` package. Retention must -/// never evict these: the index is pointing at their bytes right now. pub fn serving_release_ids(db: &Db, pkgbase_id: i64) -> Result<Vec<i64>> { db.read(|c| { let mut st = c.prepare( @@ -1441,12 +1335,8 @@ pub fn serving_release_ids(db: &Db, pkgbase_id: i64) -> Result<Vec<i64>> { }) } -/// The three paths one artifact row points at: the package, its signature and -/// its build log. Any of them can be absent (an unsigned build, a log that was -/// already purged). pub type ArtifactPaths = (Option<String>, Option<String>, Option<String>); -/// The artifact paths one release holds: package, signature, build log. pub fn release_artifact_paths(db: &Db, release_id: i64) -> Result<Vec<ArtifactPaths>> { db.read(|c| { let mut st = c.prepare( @@ -1464,9 +1354,6 @@ pub fn release_artifact_paths(db: &Db, release_id: i64) -> Result<Vec<ArtifactPa }) } -/// Mark a release and the artifacts behind it as purged, in one transaction. -/// Half-marking them would leave the next retention pass believing the files are -/// still retained. pub fn mark_release_purged(writer: &Writer, release_id: i64) -> Result<()> { let at = time::now(); writer.tx(move |tx| { @@ -1480,8 +1367,6 @@ pub fn mark_release_purged(writer: &Writer, release_id: i64) -> Result<()> { }) } -/// Record a retention run, which is what the ops page and the `last_gc_age` -/// metric read. pub fn record_gc_run(writer: &Writer, at: &str, kept: i64, evicted: i64, files_removed: i64, bytes_freed: i64, staging_swept: i64) -> Result<()> { let at = at.to_string(); writer.tx(move |tx| { @@ -1496,8 +1381,6 @@ pub fn record_gc_run(writer: &Writer, at: &str, kept: i64, evicted: i64, files_r // ------------------------------------------------------- invariant helpers -- -/// I1: every artifact in a served repo index traces to an approval row. -/// Returns offending package names; empty means the invariant holds. pub fn unapproved_index_entries(db: &Db) -> Result<Vec<String>> { db.read(|c| { let mut stmt = c.prepare( @@ -1515,8 +1398,6 @@ pub fn unapproved_index_entries(db: &Db) -> Result<Vec<String>> { }) } -/// I8: the set of packages in the index is exactly the set of -/// `current_accepted_release` pointers for active subscriptions. pub fn index_pkgbase_drift(db: &Db) -> Result<(Vec<String>, Vec<String>)> { db.read(|c| { let mut orphans = Vec::new(); @@ -1548,15 +1429,10 @@ pub fn index_pkgbase_drift(db: &Db) -> Result<(Vec<String>, Vec<String>)> { }) } -/// An approved change whose build failed and never reached the index (§8.4). A -/// human said yes, the build died, and the index is quietly still serving the -/// previous version; surfacing that is the whole point. #[derive(Debug, Clone)] pub struct Unbuilt { pub pkgbase: String, - /// The version that was approved but never published. pub approved: String, - /// The version the index actually serves, empty if nothing is served. pub serving: String, pub error: String, pub build_id: String, @@ -1564,9 +1440,6 @@ pub struct Unbuilt { pub fn approved_but_unbuilt(db: &Db) -> Result<Vec<Unbuilt>> { db.read(|c| { - // The version strings are assembled in Rust by `pkgver::full_version`, - // not by a CASE expression here (m-18): a second copy of the - // epoch-omission rule in SQL is a second rule that can disagree. let mut stmt = c.prepare( "SELECT p.name, cnd.epoch, cnd.pkgver, cnd.pkgrel, @@ -1603,9 +1476,6 @@ pub fn approved_but_unbuilt(db: &Db) -> Result<Vec<Unbuilt>> { let (pkgbase, ae, av, ar, se, sv, sr, error, build_id) = r?; let (pkgbase, av, ar) = match (pkgbase, av, ar) { (Some(p), Some(v), Some(rel)) => (p, v, rel), - // The join guarantees a pkgbase, and a failed build with a - // candidate always has one; a missing version means the schema - // was violated, so say so rather than show a blank. _ => { return Err(crate::error::Error::Db( "failed build row without a candidate version".into(), |
