From a2bcdb1cfdad17d4d7d1eccee065cdf41a3d6002 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 19 Jan 2020 16:55:39 -0800 Subject: [PATCH] Fix the progress indicator bug I had introduced in working on FeedlyOperation. Make sure FeedlyOperation calls downloadProgress.completeTask(), and make sure that all paths lead there. --- .../Feedly/Operations/FeedlyAddExistingFeedOperation.swift | 1 + .../Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift | 1 + .../Feedly/Operations/FeedlyDownloadArticlesOperation.swift | 2 +- Frameworks/Account/Feedly/Operations/FeedlyOperation.swift | 2 ++ .../Account/Feedly/Operations/FeedlySyncAllOperation.swift | 1 + .../Feedly/Operations/FeedlySyncStreamContentsOperation.swift | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Frameworks/Account/Feedly/Operations/FeedlyAddExistingFeedOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyAddExistingFeedOperation.swift index d79367e24..3fded3d36 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyAddExistingFeedOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyAddExistingFeedOperation.swift @@ -51,6 +51,7 @@ class FeedlyAddExistingFeedOperation: FeedlyOperation, FeedlyOperationDelegate, override func didCancel() { operationQueue.cancelAllOperations() addCompletionHandler = nil + super.didCancel() } func feedlyOperation(_ operation: FeedlyOperation, didFailWith error: Error) { diff --git a/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift index 7cf8cb7c2..62edf7a54 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift @@ -64,6 +64,7 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl override func didCancel() { operationQueue.cancelAllOperations() addCompletionHandler = nil + super.didCancel() } func feedlySearchOperation(_ operation: FeedlySearchOperation, didGet response: FeedlyFeedsSearchResponse) { diff --git a/Frameworks/Account/Feedly/Operations/FeedlyDownloadArticlesOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyDownloadArticlesOperation.swift index 49abcaee3..551b46cb7 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyDownloadArticlesOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyDownloadArticlesOperation.swift @@ -73,7 +73,7 @@ class FeedlyDownloadArticlesOperation: FeedlyOperation { // TODO: fix error on below line: "Expression type '()' is ambiguous without more context" //os_log(.debug, log: log, "Cancelling %{public}@.", self) operationQueue.cancelAllOperations() - didFinish() + super.didCancel() } } diff --git a/Frameworks/Account/Feedly/Operations/FeedlyOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyOperation.swift index 5cf77915b..e25ae63b0 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyOperation.swift @@ -48,6 +48,7 @@ class FeedlyOperation: MainThreadOperation { if !isCanceled { operationDelegate?.operationDidComplete(self) } + downloadProgress?.completeTask() } func didFinish(with error: Error) { @@ -56,5 +57,6 @@ class FeedlyOperation: MainThreadOperation { } func didCancel() { + didFinish() } } diff --git a/Frameworks/Account/Feedly/Operations/FeedlySyncAllOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlySyncAllOperation.swift index 75282138a..5aa2170dc 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlySyncAllOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlySyncAllOperation.swift @@ -138,6 +138,7 @@ final class FeedlySyncAllOperation: FeedlyOperation { os_log(.debug, log: log, "Cancelling sync %{public}@", syncUUID.uuidString) self.operationQueue.cancelAllOperations() syncCompletionHandler = nil + super.didCancel() } } diff --git a/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift index f41da3524..48e3cee51 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift @@ -52,6 +52,7 @@ final class FeedlySyncStreamContentsOperation: FeedlyOperation, FeedlyOperationD override func didCancel() { os_log(.debug, log: log, "Canceling sync stream contents") operationQueue.cancelAllOperations() + super.didCancel() } func enqueueOperations(for continuation: String?) {