# RSS Cache Preservation Design

## Problem

When a YouTube RSS refresh fails because the endpoint returns blocked, malformed, or otherwise non-feed content, FreeTube can replace a channel's existing cached subscription videos with an empty array. The subscription feed then appears empty even though useful stale data exists locally.

## Goal

Preserve existing subscription cache data unless a refresh has produced a valid result. A failed RSS fetch or parse must not delete the previous videos, shorts, or live entries.

## Approach

RSS parsing should represent malformed RSS as a failure, not as a successful empty feed. Callers should skip cache writes when RSS refreshes fail. Cache update actions should also accept a `replaceExisting` flag so callers can explicitly avoid destructive empty replacements while keeping valid empty responses possible.

## Components

- `src/renderer/helpers/subscriptions.js`: Detect invalid RSS XML and throw parse failures instead of returning `{ videos: [] }`.
- `src/renderer/components/SubscriptionsVideos.vue`: Only dispatch cache updates for successful RSS results; mark RSS cache writes as non-destructive.
- `src/renderer/components/SubscriptionsShorts.vue`: Same behavior for shorts RSS fallback.
- `src/renderer/components/SubscriptionsLive.vue`: Same behavior for live RSS fallback.
- `src/renderer/store/modules/subscription-cache.js`: Skip writes when `replaceExisting` is false and the incoming entries array is empty.

## Data Flow

1. Subscription view requests RSS data for each channel.
2. Fetch or parser failures are caught by the component refresh flow.
3. Failed channel refreshes produce no cache write.
4. Successful refreshes with entries update datastore and Vuex cache.
5. Successful empty refreshes only replace cache when the caller opts into destructive replacement.

## Error Handling

RSS parse errors should be logged by existing caller-level error handling, then the refresh should continue for other channels. The user keeps stale feed entries instead of seeing an empty channel caused by an infrastructure failure.

## Testing

Add focused tests around the RSS parser and subscription-cache store action:

- Invalid or blocked RSS content rejects instead of returning an empty videos array.
- Valid RSS with no entries can still parse as an empty result.
- Cache update actions skip datastore writes when `replaceExisting: false` and entries are empty.
- Cache update actions still write non-empty entries.

## Architecture Decisions

- Accepted: keep the change in existing helper, component, and Vuex store files because this is a narrow behavior fix.
- Accepted: use an explicit `replaceExisting` option instead of treating every empty array as failure.
- Rejected: datastore-level empty-array guard, because the datastore cannot know whether an empty replacement is valid business data.
