A feed an OPML drops takes its subscriptions and is not scanned again (#478)

On 2026-11-18 a scan's OPML sync dropped sciencedaily-latest-science-news.
drop_managed deleted the feed and its items but left its subscriptions,
and the scan, which had the feed in its list of feeds due, read it again
later in the same run and stored 60 items. The feed was then in no
catalogue but still subscribed to: All Subscriptions, which reads
subscriptions, listed its items, while the feed list, which reads the
catalogue, left it out, so the page had no name to put beside them and
sharing one answered 404.

drop_managed now deletes the feed's subscriptions too, and sync_group
returns the ids it dropped so the scan skips them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVAJFkEgz9cXG3jG1Zy
This commit is contained in:
2026-11-19 07:30:52 -05:00
parent 9c9c513419
commit 6939fd1dcc
4 changed files with 33 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- A feed an OPML stops listing leaves All Subscriptions with it, rather than its items staying there with no feed name beside them: the scan no longer reads it again after the list drops it, and its subscriptions go with it (#478).
- Searching All Subscriptions answers in a fraction of a second, not five: a search reads each item's title and text without its markup, indexed on Postgres, and still finds part of a word. It no longer matches words inside the HTML's tags, such as a link's address. Text past the first 4,000 characters of a very long post is not searched (#459, #472).
- Artwork that cannot be shown is asked for again a day later rather than every hour: one too large is refused on its stated size before it is read, and a refusal from the publisher or one ipx makes (too large, not an image) is remembered for a day; JPEG XL pictures sent without a type are shown (#448).
- `ipx reap --dry-run` says "would delete" of each file and of the total, rather than "deleted", word for word a real reap, of files it kept (#461).

View File

@@ -2599,6 +2599,8 @@ impl Db {
self.exec("DELETE FROM feeds WHERE id = $1 AND managed", vec![id.into()]).await?;
self.exec("DELETE FROM entries WHERE feed_id = $1", vec![id.into()]).await?;
self.exec("DELETE FROM enclosures WHERE feed_id = $1 AND path IS NULL", vec![id.into()]).await?;
// Left behind, All Subscriptions listed the items of a feed no list had a name for (#478).
self.exec("DELETE FROM subscriptions WHERE feed_id = $1", vec![id.into()]).await?;
Ok(())
}

View File

@@ -182,7 +182,7 @@ pub(crate) async fn sync_group(ctx: &Arc<Ctx>, parent_id: &str, listed: &[(Strin
.await?;
// Anything in this group the OPML no longer lists.
let mut removed = 0;
let mut removed = vec![];
let mut kept = 0;
let parent = ctx.cfg().feeds.get(parent_id).cloned();
async {
@@ -203,7 +203,7 @@ pub(crate) async fn sync_group(ctx: &Arc<Ctx>, parent_id: &str, listed: &[(Strin
tracing::info!(feed = %m.id, "dropped from the OPML but has downloads; keeping it");
} else {
ctx.db.drop_managed(&m.id).await?;
removed += 1;
removed.push(m.id.clone());
tracing::info!(feed = %m.id, "dropped from the OPML with nothing downloaded; removed");
}
}
@@ -291,4 +291,21 @@ mod tests {
assert!(ctx.db.subscription(me, "b").await.unwrap().is_some());
assert!(ctx.db.subscription(you, "b").await.unwrap().is_none());
}
#[tokio::test]
async fn a_feed_the_list_drops_takes_its_subscriptions_with_it() {
let mut cfg = config::Config::default();
cfg.feeds.insert("opml".into(), feed());
let ctx = Arc::new(test_ctx(cfg).await);
let me = ctx.db.create_user("me", None, false).await.unwrap();
ctx.db.upsert_managed("a", "http://x/a.xml", "a", "opml").await.unwrap();
ctx.db.subscribe(me, "opml").await.unwrap();
ctx.db.subscribe(me, "a").await.unwrap();
// Left subscribed, All Subscriptions listed a's items with no feed to name them (#478).
let Outcome::Opml { removed, .. } = sync_group(&ctx, "opml", &[]).await.unwrap() else { panic!("a list") };
assert_eq!(removed, ["a"], "the scan is told, so it does not read a again");
assert!(ctx.db.subscription(me, "a").await.unwrap().is_none());
assert!(ctx.db.subscription(me, "opml").await.unwrap().is_some());
}
}

View File

@@ -5,6 +5,7 @@ use crate::ctx::Ctx;
use crate::ipc::Event;
use crate::{catalogue, cli, config, db, download, feed, lists, metrics, signals, torrent};
use anyhow::Result;
use std::collections::HashSet;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
@@ -23,6 +24,8 @@ pub(crate) async fn fetch(ctx: &Arc<Ctx>, only: Option<&str>, force: bool, scope
let subscribed = ctx.db.subscriber_counts().await?;
let mut scanned = 0;
let mut fresh: Vec<String> = vec![];
// Feeds a list read earlier in this run dropped: still in `due`, scanned they came back (#478).
let mut dropped: HashSet<String> = HashSet::new();
let in_scope =
|s: &Sub| scope.is_empty() || scope.contains(&s.id) || s.cfg.group.as_ref().is_some_and(|g| scope.contains(g));
let mut states = ctx.db.http_states().await?;
@@ -95,6 +98,9 @@ pub(crate) async fn fetch(ctx: &Arc<Ctx>, only: Option<&str>, force: bool, scope
let (id, feed_cfg) = (&sub.id, &sub.cfg);
// A task that panicked has no body; scan_one then fetches it itself.
let fetched = futures_util::StreamExt::next(&mut bodies).await.and_then(|j| j.ok()).flatten();
if dropped.contains(id) {
continue;
}
scanned += 1;
ctx.out.emit(Event::FeedStart { feed: id.clone() });
match scan_one(ctx, id, feed_cfg, state, force, fetched).await {
@@ -113,10 +119,12 @@ pub(crate) async fn fetch(ctx: &Arc<Ctx>, only: Option<&str>, force: bool, scope
ctx.out.emit(Event::FeedSkip {
feed: id.clone(),
reason: format!(
"{total} feed(s) listed, {} added, {removed} unsubscribed, {kept} kept without a listing",
added.len()
"{total} feed(s) listed, {} added, {} unsubscribed, {kept} kept without a listing",
added.len(),
removed.len()
),
});
dropped.extend(removed);
// Read them in the same pass, as the original did, rather than making
// the user wait a whole interval for a newly listed show.
fresh.extend(added);
@@ -247,7 +255,7 @@ pub(crate) enum Outcome {
/// The URL is a list of feeds rather than a feed: an OPML, or a Patreon creator's shows.
Opml {
added: Vec<String>,
removed: usize,
removed: Vec<String>,
kept: usize,
total: usize,
},