diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index 23dc52572..c548f012b 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -323,8 +323,9 @@ import Secrets do { return try await account.logActivity(kind: .sendArticleStatuses, successMessage: successMessage, durationIsSignificant: durationIsSignificant) { () -> Int in + // A failed read must not read as “nothing to send” — zero would arm the no-change backoff. guard let syncStatuses = await syncDatabase.selectForProcessing() else { - return 0 + throw FeedlyAccountDelegateError.databaseReadFailed } var savedError: Error? @@ -1017,9 +1018,10 @@ private extension FeedlyAccountDelegate { let newerThan = Date().bySubtracting(days: Self.streamIngestDaysLimit) let (remoteUnreadIDs, truncated) = try await collectStreamIDs(for: account, resource: resource, kind: .refreshArticleStatuses, newerThan: newerThan, unreadOnly: true) - // A failed pending-statuses read must not be treated as “nothing pending” — that would revert pending changes. + // A failed pending-statuses read must not read as “nothing pending” — that would + // revert pending edits and arm the no-change backoff. guard let pendingArticleIDs = await syncDatabase.selectPendingReadStatusArticleIDs() else { - return (added: 0, removed: 0) + throw FeedlyAccountDelegateError.databaseReadFailed } let adjustedRemoteUnreadIDs = remoteUnreadIDs.subtracting(pendingArticleIDs) @@ -1047,9 +1049,10 @@ private extension FeedlyAccountDelegate { let resource = FeedlyTagResourceID.Global.saved(for: userID) let (remoteStarredIDs, truncated) = try await collectStreamIDs(for: account, resource: resource, kind: .refreshArticleStatuses, unreadOnly: nil) - // A failed pending-statuses read must not be treated as “nothing pending” — that would revert pending changes. + // A failed pending-statuses read must not read as “nothing pending” — that would + // revert pending edits and arm the no-change backoff. guard let pendingArticleIDs = await syncDatabase.selectPendingStarredStatusArticleIDs() else { - return (added: 0, removed: 0) + throw FeedlyAccountDelegateError.databaseReadFailed } let adjustedRemoteStarredIDs = remoteStarredIDs.subtracting(pendingArticleIDs) diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegateError.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegateError.swift index 3b0bef73d..a87e0212e 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegateError.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegateError.swift @@ -19,6 +19,7 @@ enum FeedlyAccountDelegateError: LocalizedError { case addFeedInvalidFolder(String) // folderName case unableToRenameFeed(String, String) case unableToRemoveFeed(String) + case databaseReadFailed var errorDescription: String? { switch self { @@ -59,6 +60,9 @@ enum FeedlyAccountDelegateError: LocalizedError { case .unableToRemoveFeed(let feedName): let template = NSLocalizedString("Could not remove “%@”.", comment: "Feedly – Could not remove a feed.") return String(format: template, feedName) + + case .databaseReadFailed: + return NSLocalizedString("Could not read from the syncing database.", comment: "Feedly – Could not read from the syncing database.") } } @@ -95,6 +99,9 @@ enum FeedlyAccountDelegateError: LocalizedError { case .unableToRenameFeed: return nil + + case .databaseReadFailed: + return nil } } }