From c150d19b4ee69afd15f61f69d697d559d44890ee Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 8 Dec 2020 13:28:50 -0600 Subject: [PATCH] Fix so that feeds won't get added locally when CloudKit errors and allow the removal of corrupted Feeds when found. --- .../Account/CloudKit/CloudKitAccountDelegate.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index c9716e984..b74b4a3cf 100644 --- a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -198,7 +198,14 @@ final class CloudKitAccountDelegate: AccountDelegate { container.removeWebFeed(feed) completion(.success(())) case .failure(let error): - completion(.failure(error)) + switch error { + case CloudKitZoneError.invalidParameter: + // We got into a bad state and should remove the feed to clear up the bad data + account.clearWebFeedMetadata(feed) + container.removeWebFeed(feed) + default: + completion(.failure(error)) + } } } } @@ -708,6 +715,7 @@ private extension CloudKitAccountDelegate { feed.externalID = externalID self.sendNewArticlesToTheCloud(account, feed, completion: completion) case .failure(let error): + container.removeWebFeed(feed) self.refreshProgress.clear() completion(.failure(error)) }