From 748e979707e2f6f95729dd4b8ae6da523f053858 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sun, 29 Sep 2024 12:22:35 +0200 Subject: [PATCH] Do not overwrite cache entries when hitting RSS ratelimits (#5756) --- .../subscriptions-live/subscriptions-live.js | 19 ++++++++++++++----- .../subscriptions-shorts.js | 19 ++++++++++++++----- .../subscriptions-videos.js | 19 ++++++++++++++----- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/renderer/components/subscriptions-live/subscriptions-live.js b/src/renderer/components/subscriptions-live/subscriptions-live.js index 5153c171a4d0..b8d182621fbd 100644 --- a/src/renderer/components/subscriptions-live/subscriptions-live.js +++ b/src/renderer/components/subscriptions-live/subscriptions-live.js @@ -206,10 +206,13 @@ export default defineComponent({ channelCount++ const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100 this.setProgressBarPercentage(percentageComplete) - this.updateSubscriptionLiveCacheByChannel({ - channelId: channel.id, - videos: videos - }) + + if (videos != null) { + this.updateSubscriptionLiveCacheByChannel({ + channelId: channel.id, + videos: videos + }) + } if (name || thumbnailUrl) { subscriptionUpdates.push({ @@ -219,7 +222,7 @@ export default defineComponent({ }) } - return videos + return videos ?? [] }))).flat() this.videoList = updateVideoListAfterProcessing(videoListFromRemote) @@ -277,6 +280,12 @@ export default defineComponent({ try { const response = await fetch(feedUrl) + if (response.status === 403) { + return { + videos: null + } + } + if (response.status === 404) { // playlists don't exist if the channel was terminated but also if it doesn't have the tab, // so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated diff --git a/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js b/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js index 948e0ccc542d..a3e24e4aae13 100644 --- a/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js +++ b/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js @@ -183,10 +183,13 @@ export default defineComponent({ channelCount++ const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100 this.setProgressBarPercentage(percentageComplete) - this.updateSubscriptionShortsCacheByChannel({ - channelId: channel.id, - videos: videos - }) + + if (videos != null) { + this.updateSubscriptionShortsCacheByChannel({ + channelId: channel.id, + videos: videos + }) + } if (name) { subscriptionUpdates.push({ @@ -195,7 +198,7 @@ export default defineComponent({ }) } - return videos + return videos ?? [] }))).flat() this.videoList = updateVideoListAfterProcessing(videoListFromRemote) @@ -213,6 +216,12 @@ export default defineComponent({ try { const response = await fetch(feedUrl) + if (response.status === 403) { + return { + videos: null + } + } + if (response.status === 404) { // playlists don't exist if the channel was terminated but also if it doesn't have the tab, // so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated diff --git a/src/renderer/components/subscriptions-videos/subscriptions-videos.js b/src/renderer/components/subscriptions-videos/subscriptions-videos.js index da6edff2b2aa..e05e2422277a 100644 --- a/src/renderer/components/subscriptions-videos/subscriptions-videos.js +++ b/src/renderer/components/subscriptions-videos/subscriptions-videos.js @@ -210,10 +210,13 @@ export default defineComponent({ channelCount++ const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100 this.setProgressBarPercentage(percentageComplete) - this.updateSubscriptionVideosCacheByChannel({ - channelId: channel.id, - videos: videos - }) + + if (videos != null) { + this.updateSubscriptionVideosCacheByChannel({ + channelId: channel.id, + videos: videos + }) + } if (name || thumbnailUrl) { subscriptionUpdates.push({ @@ -223,7 +226,7 @@ export default defineComponent({ }) } - return videos + return videos ?? [] }))).flat() this.videoList = updateVideoListAfterProcessing(videoListFromRemote) @@ -281,6 +284,12 @@ export default defineComponent({ try { const response = await fetch(feedUrl) + if (response.status === 403) { + return { + videos: null + } + } + if (response.status === 404) { // playlists don't exist if the channel was terminated but also if it doesn't have the tab, // so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated