Delete orphaned sync status records.

This commit is contained in:
Maurice Parker 2021-07-08 13:09:26 -05:00
parent 1096e341d5
commit f446a7e2ea

View File

@ -130,24 +130,26 @@ private extension CloudKitSendStatusOperation {
} }
// If this happens, we have somehow gotten into a state where we have new status records // If this happens, we have somehow gotten into a state where we have new status records
// but the articles didn't come back in the fetch. Rather than crashing, we continue processing // but the articles didn't come back in the fetch. We need to clean up those sync records
// and hope that it gets cleared up later. // and continue processing.
guard !statusUpdates.isEmpty else { if statusUpdates.isEmpty {
done(false) self.database.deleteSelectedForProcessing(articleIDs) { _ in
return done(false)
} return
}
articlesZone.modifyArticles(statusUpdates) { result in } else {
switch result { articlesZone.modifyArticles(statusUpdates) { result in
case .success: switch result {
self.database.deleteSelectedForProcessing(statusUpdates.map({ $0.articleID })) { _ in case .success:
done(false) self.database.deleteSelectedForProcessing(statusUpdates.map({ $0.articleID })) { _ in
} done(false)
case .failure(let error): }
self.database.resetSelectedForProcessing(syncStatuses.map({ $0.articleID })) { _ in case .failure(let error):
self.processAccountError(account, error) self.database.resetSelectedForProcessing(syncStatuses.map({ $0.articleID })) { _ in
os_log(.error, log: self.log, "Send article status modify articles error: %@.", error.localizedDescription) self.processAccountError(account, error)
completion(true) os_log(.error, log: self.log, "Send article status modify articles error: %@.", error.localizedDescription)
completion(true)
}
} }
} }
} }