From: Simon Tatham Date: Mon, 8 Jan 2024 19:20:54 +0000 (+0000) Subject: Fix duplication of items in feeds. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=780723d7655eea34fd454db24534ba5850a2dd0f;p=mastodonochrome.git Fix duplication of items in feeds. When we request any part of the contents of a feed from the server, it provides us with followup links we can use to extend the same feed further into the past or future. But if we're extending it further into the past than we had, we shouldn't save the future link we get back, because it's not as good as the future link we already had. And vice versa. The effect of this bug was that after extending a feed into the past, the next extension into the future would start from the past fragment's future extension and re-retrieve all the items we already had. And we wouldn't notice, and would store a second copy of all their ids in our list. --- diff --git a/src/client.rs b/src/client.rs index 7f0110c..e16d92e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -837,8 +837,19 @@ impl Client { // Confusingly, the Mastodon protocol considers // "next" to be heading into the past and "prev" // the future. - Some("next") => feed.extend_past = Some(link.queries), - Some("prev") => feed.extend_future = Some(link.queries), + // + // We only keep the extension link for directions + // that are the current frontier. If we're + // extending an existing feed further into the + // past, then the future link we have already is + // better than the new one (which will cause us to + // re-fetch stuff we already had). And vice versa. + Some("next") => if ext != FeedExtend::Future { + feed.extend_past = Some(link.queries); + } + Some("prev") => if ext != FeedExtend::Past { + feed.extend_future = Some(link.queries); + } _ => (), } }