summaryrefslogtreecommitdiffstats
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/render.rs15
-rw-r--r--src/http/routes.rs51
2 files changed, 64 insertions, 2 deletions
diff --git a/src/http/render.rs b/src/http/render.rs
index 9e3d801..d715a71 100644
--- a/src/http/render.rs
+++ b/src/http/render.rs
@@ -192,12 +192,25 @@ pub struct Attention {
pub page: Page,
pub empty: bool,
pub notices: Vec<NoticeRow>,
+ pub unbuilt: Vec<UnbuiltRow>,
pub outdated: Vec<StaleRow>,
pub missing: Vec<StaleRow>,
pub downgrades: Vec<StaleRow>,
pub blocked: Vec<BlockedRow>,
}
+/// §8.4: an approval whose build failed. The index is still serving the older
+/// version and nothing about the package looks wrong from the outside, so this
+/// row exists to be impossible to miss.
+#[derive(Debug, Clone)]
+pub struct UnbuiltRow {
+ pub pkgbase: String,
+ pub approved: String,
+ pub serving: String,
+ pub error: String,
+ pub build_id: String,
+}
+
#[derive(Debug, Clone)]
pub struct NoticeRow {
pub id: i64,
@@ -251,6 +264,8 @@ pub struct PackageDetail {
pub summary: String,
pub can_withdraw: bool,
pub stale: Vec<String>,
+ /// "v2 approved, build failed, index still serving v1" (§8.4).
+ pub unbuilt: Vec<UnbuiltRow>,
pub deps_in: Vec<String>,
pub deps_out: Vec<String>,
pub timeline: Vec<TimelineRow>,
diff --git a/src/http/routes.rs b/src/http/routes.rs
index ab68069..6b01611 100644
--- a/src/http/routes.rs
+++ b/src/http/routes.rs
@@ -77,6 +77,7 @@ pub fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
("GET", ["builds", id]) => build_detail(state, req, id),
("GET", ["builds", id, "log.txt"]) => build_log(state, id),
("POST", ["builds", id, "cancel"]) => build_cancel(state, req, id),
+ ("POST", ["builds", id, "requeue"]) => build_retry(state, req, id),
("GET", ["audit"]) => audit(state, req),
("GET", ["settings"]) => settings(state, req),
_ => not_found(state, req),
@@ -605,9 +606,24 @@ fn attention(state: &State, req: &Req) -> Res {
.into_iter()
.map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now })
.collect();
- let empty = notices.is_empty() && outdated.is_empty() && missing.is_empty() && blocked.is_empty();
+ let unbuilt: Vec<UnbuiltRow> = db::approved_but_unbuilt(db)
+ .unwrap_or_default()
+ .into_iter()
+ .map(|u| UnbuiltRow {
+ pkgbase: u.pkgbase,
+ approved: u.approved,
+ serving: u.serving,
+ error: u.error,
+ build_id: u.build_id,
+ })
+ .collect();
+ let empty = notices.is_empty()
+ && unbuilt.is_empty()
+ && outdated.is_empty()
+ && missing.is_empty()
+ && blocked.is_empty();
page_to_res(
- Attention { page, empty, notices, outdated, missing, downgrades, blocked },
+ Attention { page, empty, notices, unbuilt, outdated, missing, downgrades, blocked },
200,
)
}
@@ -713,12 +729,25 @@ fn package_detail(state: &State, req: &Req, name: &str) -> Res {
Some(r) => format!("serving {} · approved from aur_commit {}", r.version(), short(&r.aur_commit)),
None => "nothing published yet".into(),
};
+ let unbuilt: Vec<UnbuiltRow> = db::approved_but_unbuilt(db)
+ .unwrap_or_default()
+ .into_iter()
+ .filter(|u| u.pkgbase == name)
+ .map(|u| UnbuiltRow {
+ pkgbase: u.pkgbase,
+ approved: u.approved,
+ serving: u.serving,
+ error: u.error,
+ build_id: u.build_id,
+ })
+ .collect();
page_to_res(
PackageDetail {
page,
name: name.to_string(),
summary,
can_withdraw: accepted.is_some(),
+ unbuilt,
stale,
deps_in,
deps_out,
@@ -899,6 +928,24 @@ fn build_cancel(state: &State, req: &Req, id: &str) -> Res {
builds_with(state, req, page)
}
+/// Retrying a failed build is an explicit, audited decision (§8.4), not
+/// something the system does to itself.
+fn build_retry(state: &State, req: &Req, id: &str) -> Res {
+ match builds::retry(&state.db, id) {
+ Ok(()) => {
+ let _ = db::audit(&state.db.writer, "web", "web", "build.retry", "build", id, serde_json::json!({}));
+ Res::redirect(&format!("/builds/{id}"))
+ }
+ Err(e) => {
+ let mut page = chrome(state, req, "Builds", "nav_builds");
+ page.flash = format!("could not retry: {e}");
+ page.has_flash = true;
+ page.flash_err = true;
+ builds_with(state, req, page)
+ }
+ }
+}
+
// ----------------------------------------------------------- ops, config --
fn audit(state: &State, req: &Req) -> Res {