From a406fa9d4d0ccb07452449d8af83f281f3aa7821 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 21 May 2019 19:15:24 -0500 Subject: [PATCH] Enhance error handling to make syncing more resilient to network failures. --- Frameworks/Account/Feedbin/FeedbinAPICaller.swift | 4 +++- Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Frameworks/Account/Feedbin/FeedbinAPICaller.swift b/Frameworks/Account/Feedbin/FeedbinAPICaller.swift index 320539e55..ef8c1f6cf 100644 --- a/Frameworks/Account/Feedbin/FeedbinAPICaller.swift +++ b/Frameworks/Account/Feedbin/FeedbinAPICaller.swift @@ -428,6 +428,7 @@ final class FeedbinAPICaller: NSObject { completion(.success((entries, pagingInfo.nextPage, lastPageNumber))) case .failure(let error): + self?.accountMetadata?.lastArticleFetch = nil completion(.failure(error)) } @@ -444,7 +445,7 @@ final class FeedbinAPICaller: NSObject { let request = URLRequest(url: callURL, credentials: credentials) - transport.send(request: request, resultType: [FeedbinEntry].self) { result in + transport.send(request: request, resultType: [FeedbinEntry].self) { [weak self] result in switch result { case .success(let (response, entries)): @@ -453,6 +454,7 @@ final class FeedbinAPICaller: NSObject { completion(.success((entries, pagingInfo.nextPage))) case .failure(let error): + self?.accountMetadata?.lastArticleFetch = nil completion(.failure(error)) } diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index d7ab8c3d3..f27246187 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -164,6 +164,7 @@ final class FeedbinAccountDelegate: AccountDelegate { case .failure(let error): guard let self = self else { return } os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription) + group.leave() } } @@ -177,6 +178,7 @@ final class FeedbinAccountDelegate: AccountDelegate { case .failure(let error): guard let self = self else { return } os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription) + group.leave() } } @@ -1068,6 +1070,7 @@ private extension FeedbinAccountDelegate { case .failure(let error): guard let self = self else { return } os_log(.error, log: self.log, "Refresh articles for additional pages failed: %@.", error.localizedDescription) + completion() } }