From 295d4576e0d0be9ecf0ec00afcc38c9f34ad155a Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 1 Dec 2024 17:10:35 -0800 Subject: [PATCH] Save cacheControlInfo with the feed. --- .../Account/LocalAccount/LocalAccountRefresher.swift | 10 +++++++--- Account/Sources/Account/WebFeed.swift | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift b/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift index fe39de0aa..fa37a5cdc 100644 --- a/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift +++ b/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift @@ -89,6 +89,11 @@ extension LocalAccountRefresher: DownloadSessionDelegate { return } + if let error { + os_log(.debug, "Error downloading \(url) - \(error)") + return + } + let conditionalGetInfo: HTTPConditionalGetInfo? = { if let httpResponse = response as? HTTPURLResponse { return HTTPConditionalGetInfo(urlResponse: httpResponse) @@ -96,9 +101,8 @@ extension LocalAccountRefresher: DownloadSessionDelegate { return nil }() - if let error { - os_log(.debug, "Error downloading \(url) - \(error)") - return + if let httpURLResponse = response as? HTTPURLResponse, let cacheControlInfo = CacheControlInfo(urlResponse: httpURLResponse) { + feed.cacheControlInfo = cacheControlInfo } let dataHash = data.md5String diff --git a/Account/Sources/Account/WebFeed.swift b/Account/Sources/Account/WebFeed.swift index a6db55552..7ca28e5f4 100644 --- a/Account/Sources/Account/WebFeed.swift +++ b/Account/Sources/Account/WebFeed.swift @@ -132,6 +132,15 @@ public final class WebFeed: Feed, Renamable, Hashable { } } + public var cacheControlInfo: CacheControlInfo? { + get { + metadata.cacheControlInfo + } + set { + metadata.cacheControlInfo = newValue + } + } + public var contentHash: String? { get { return metadata.contentHash