Feeds from before site icons get one, without waiting for a post (#73)
The icon lookup ran only when a scan got the feed's body, and most feeds answer 304 to their stored validators, so anildash.com and 68 others stayed blank until their next post. A feed whose image was never looked for is now refetched once without validators, as an empty one already was. A miss is stored as "" (drawn as no art), so neither the refetch nor the site lookup repeats on every scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -1178,8 +1178,10 @@ async fn scan_one(
|
|||||||
// A 304 while nothing is stored means the validator has outlived the data -- a restore
|
// A 304 while nothing is stored means the validator has outlived the data -- a restore
|
||||||
// from backup, a manual edit, a cleanup that removed entries. Believe the database over
|
// from backup, a manual edit, a cleanup that removed entries. Believe the database over
|
||||||
// the validator: drop it and ask again, or the feed stays empty until the publisher
|
// the validator: drop it and ask again, or the feed stays empty until the publisher
|
||||||
// happens to change something.
|
// happens to change something. The same for artwork never looked for: a feed from before
|
||||||
if matches!(fetched, feed::Fetched::NotModified) && ctx.db.feed_summary(id).await?.entries == 0 {
|
// site icons (#73) would otherwise wait for its next post to get one.
|
||||||
|
let stored = ctx.db.feed_summary(id).await?;
|
||||||
|
if matches!(fetched, feed::Fetched::NotModified) && (stored.entries == 0 || stored.image.is_none()) {
|
||||||
tracing::info!(feed = id, "not modified, but nothing stored; refetching without the validator");
|
tracing::info!(feed = id, "not modified, but nothing stored; refetching without the validator");
|
||||||
ctx.db.clear_validators(id).await?;
|
ctx.db.clear_validators(id).await?;
|
||||||
fetched = feed::fetch(&ctx.client, feed_cfg, None, None).await?;
|
fetched = feed::fetch(&ctx.client, feed_cfg, None, None).await?;
|
||||||
@@ -1206,13 +1208,13 @@ async fn scan_one(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut parsed = feed::parse(&bytes)?;
|
let mut parsed = feed::parse(&bytes)?;
|
||||||
// ponytail: a site with no icon at all is asked again on every scan that finds the feed
|
// Looked for once. A miss is stored as "", which the page draws as no art, so a site with
|
||||||
// changed; remember the miss in the feeds table if that turns out to cost.
|
// no icon is not asked again on every scan, nor the feed refetched in full for it above.
|
||||||
if parsed.image.is_none()
|
if parsed.image.is_none() && stored.image.is_none() {
|
||||||
&& let Some(site) = &parsed.site
|
parsed.image = Some(match &parsed.site {
|
||||||
&& ctx.db.feed_summary(id).await?.image.is_none()
|
Some(site) => feed::site_icon(&ctx.client, site).await.unwrap_or_default(),
|
||||||
{
|
None => String::new(),
|
||||||
parsed.image = feed::site_icon(&ctx.client, site).await;
|
});
|
||||||
}
|
}
|
||||||
ctx.db.record_feed(
|
ctx.db.record_feed(
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user