summaryrefslogtreecommitdiffstats
path: root/src/watch
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch')
-rw-r--r--src/watch/detect.rs12
-rw-r--r--src/watch/staleness.rs42
2 files changed, 54 insertions, 0 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index 084052f..55b7543 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -20,6 +20,8 @@ use crate::watch::mirror::{read_tree, sync_mirror, Sync};
pub enum Outcome {
/// Nothing moved at all.
NoChange,
+ /// The subscription is paused: we look at nothing and change nothing.
+ Paused,
/// A new review was opened.
Candidate { id: i64, kind: String },
/// The open review was updated in place (I7).
@@ -47,6 +49,16 @@ pub struct CheckReport {
pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
let pb = get_pkgbase(db, name)?
.ok_or_else(|| crate::error::Error::not_found(format!("pkgbase {name}")))?;
+ // A paused subscription is not observed at all. Pausing because a package is
+ // broken must not keep opening reviews nobody is going to act on, and it
+ // must not keep polling AUR either. The pause lives on the subscription, so
+ // that is what we consult.
+ let paused = db::get_subscription(db, name)?
+ .map(|s| s.state == subscription_state::PAUSED)
+ .unwrap_or(false);
+ if paused {
+ return Ok(CheckReport { pkgbase: name.into(), head: String::new(), outcome: Outcome::Paused });
+ }
let sync = sync_mirror(cfg, db, name, &pb.aur_url)?;
let head = match &sync {
Sync::Gone => {
diff --git a/src/watch/staleness.rs b/src/watch/staleness.rs
index 40bafeb..210632e 100644
--- a/src/watch/staleness.rs
+++ b/src/watch/staleness.rs
@@ -86,6 +86,48 @@ pub fn stale_for(db: &Db, pkgbase: &str) -> Result<Vec<Stale>> {
Ok(stale_rows(db)?.into_iter().filter(|s| s.pkgbase == pkgbase).collect())
}
+/// AUR now offers a **lower** version than we serve (§10.2). This is not a
+/// build request; it is an announcement that the mirror and the upstream have
+/// disagreed, and someone has to decide which one consumers follow.
+///
+/// Derived on read from the newest candidate per pkgbase against the accepted
+/// release, so it disappears the moment either side moves.
+pub fn downgrades(db: &Db) -> Result<Vec<Stale>> {
+ let rows: Vec<(String, String, String)> = db.read(|c| {
+ let mut st = c.prepare(
+ "SELECT p.name, r.pkgver, (
+ SELECT c.pkgver FROM candidate c
+ WHERE c.pkgbase_id = r.pkgbase_id
+ ORDER BY c.id DESC LIMIT 1)
+ FROM release r
+ JOIN pkgbase p ON p.current_accepted_release_id = r.id
+ WHERE r.state = 'published'",
+ )?;
+ let rows = st.query_map([], |r| {
+ Ok((
+ r.get::<_, String>(0)?,
+ r.get::<_, String>(1)?,
+ r.get::<_, Option<String>>(2)?.unwrap_or_default(),
+ ))
+ })?;
+ Ok(rows.filter_map(|r| r.ok()).collect::<Vec<_>>())
+ })?;
+ let mut out = Vec::new();
+ for (pkgbase, served, offered) in rows {
+ if offered.is_empty() || !crate::pkgver::is_downgrade(&served, &offered) {
+ continue;
+ }
+ out.push(Stale {
+ kind: Kind::Outdated,
+ pkgbase: pkgbase.clone(),
+ dependency: "aur".into(),
+ built_with: served,
+ now: offered,
+ });
+ }
+ Ok(out)
+}
+
/// "If I approve this, what goes stale?" — the dependents question (§10.3).
/// A package depends on `name` if `name` appears in its recorded world or in
/// its recipe dependencies.