Fix legacy sync queue state if a feed is both added and removed (#7768)

This commit is contained in:
jeroenmuller 2025-05-31 08:35:41 +02:00 committed by GitHub
parent 1e6fb8fc46
commit a244fe0897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -201,6 +201,9 @@ public class SyncService extends Worker {
.uploadSubscriptionChanges(queuedAddedFeeds, queuedRemovedFeeds);
synchronizationQueueStorage.clearFeedQueues();
newTimeStamp = uploadResponse.timestamp;
} catch (SyncServiceException exception) {
synchronizationQueueStorage.removeLegacyConflictingFeedEntries(localSubscriptions);
throw exception;
} finally {
LockingAsyncExecutor.unlock();
}

View File

@ -8,6 +8,8 @@ import org.json.JSONArray;
import org.json.JSONException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import de.danoeh.antennapod.storage.preferences.SynchronizationSettings;
@ -109,6 +111,22 @@ public class SynchronizationQueueStorage {
}
}
/** Remove feed entries that conflict with the given list of current local subscriptions.
* <>
* This is only relevant for old clients that have legacy data. In newer versions, `enqueueFeedAdded`
* and `enqueueFeedAdded` already take care of removing conflicting entries.
* */
protected void removeLegacyConflictingFeedEntries(Collection<String> currentLocalSubscriptions) {
List<String> removedQueue = this.getQueuedRemovedFeeds();
List<String> addedQueue = this.getQueuedAddedFeeds();
removedQueue.removeAll(currentLocalSubscriptions);
addedQueue.removeAll(removedQueue);
sharedPreferences.edit()
.putString(QUEUED_FEEDS_ADDED, addedQueue.toString())
.putString(QUEUED_FEEDS_REMOVED, removedQueue.toString())
.apply();
}
protected void enqueueFeedRemoved(String downloadUrl) {
SharedPreferences sharedPreferences = getSharedPreferences();
try {