diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 4b70bf4dd..76a6a9206 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -919,6 +919,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, // MARK: - Debug + public func debugDropConditionalGetInfo() { +#if DEBUG + for feed in flattenedWebFeeds() { + feed.dropConditionalGetInfo() + } +#endif + } + public func debugRunSearch() { #if DEBUG let t1 = Date() diff --git a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index 241522adc..dd752c721 100644 --- a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -792,6 +792,7 @@ private extension CloudKitAccountDelegate { return } self.articlesZone.deleteArticles(webFeedExternalID) { result in + feed.dropConditionalGetInfo() self.syncProgress.completeTask() completion(result) } diff --git a/Account/Sources/Account/CloudKit/CloudKitAccountZoneDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitAccountZoneDelegate.swift index fe9a0ca09..d03b917be 100644 --- a/Account/Sources/Account/CloudKit/CloudKitAccountZoneDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitAccountZoneDelegate.swift @@ -82,8 +82,9 @@ class CloudKitAcountZoneDelegate: CloudKitZoneDelegate { func removeWebFeed(_ externalID: String) { if let webFeed = account?.existingWebFeed(withExternalID: externalID), let containers = account?.existingContainers(withWebFeed: webFeed) { - containers.forEach { - $0.removeWebFeed(webFeed) + for container in containers { + webFeed.dropConditionalGetInfo() + container.removeWebFeed(webFeed) } } } diff --git a/Account/Sources/Account/DataExtensions.swift b/Account/Sources/Account/DataExtensions.swift index 12349740d..61ddc93cd 100644 --- a/Account/Sources/Account/DataExtensions.swift +++ b/Account/Sources/Account/DataExtensions.swift @@ -26,6 +26,7 @@ public extension WebFeed { public static let editedName = "editedName" public static let authors = "authors" public static let contentHash = "contentHash" + public static let conditionalGetInfo = "conditionalGetInfo" } } diff --git a/Account/Sources/Account/WebFeed.swift b/Account/Sources/Account/WebFeed.swift index b19737e9e..a6db55552 100644 --- a/Account/Sources/Account/WebFeed.swift +++ b/Account/Sources/Account/WebFeed.swift @@ -123,6 +123,15 @@ public final class WebFeed: Feed, Renamable, Hashable { } } + public var conditionalGetInfo: HTTPConditionalGetInfo? { + get { + return metadata.conditionalGetInfo + } + set { + metadata.conditionalGetInfo = newValue + } + } + public var contentHash: String? { get { return metadata.contentHash @@ -235,6 +244,13 @@ public final class WebFeed: Feed, Renamable, Hashable { self.metadata = metadata } + // MARK: - API + + public func dropConditionalGetInfo() { + conditionalGetInfo = nil + contentHash = nil + } + // MARK: - Hashable public func hash(into hasher: inout Hasher) { diff --git a/Account/Sources/Account/WebFeedMetadata.swift b/Account/Sources/Account/WebFeedMetadata.swift index 4c7b29bb9..924472089 100644 --- a/Account/Sources/Account/WebFeedMetadata.swift +++ b/Account/Sources/Account/WebFeedMetadata.swift @@ -26,6 +26,7 @@ final class WebFeedMetadata: Codable { case contentHash case isNotifyAboutNewArticles case isArticleExtractorAlwaysOn + case conditionalGetInfo case externalID = "subscriptionID" case folderRelationship } @@ -102,6 +103,14 @@ final class WebFeedMetadata: Codable { } } + var conditionalGetInfo: HTTPConditionalGetInfo? { + didSet { + if conditionalGetInfo != oldValue { + valueDidChange(.conditionalGetInfo) + } + } + } + var externalID: String? { didSet { if externalID != oldValue { diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 4b05e161d..5baa8a438 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -704,6 +704,14 @@ extension AppDelegate { AccountManager.shared.defaultAccount.debugRunSearch() } + @IBAction func debugDropConditionalGetInfo(_ sender: Any?) { +#if DEBUG + for account in AccountManager.shared.activeAccounts { + account.debugDropConditionalGetInfo() + } +#endif + } + @IBAction func debugTestCrashReporterWindow(_ sender: Any?) { #if DEBUG crashReportWindowController = CrashReportWindowController(crashLogText: "This is a test crash log.")