From 8239e7af20bc6e3096bf89e47b7177227bfe015e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 30 Oct 2026 21:30:24 -0700 Subject: [PATCH] Record decode failures but not download failures (since DownloadedImageCache does that). --- .../Sources/Images/FaviconDownloader.swift | 7 ------- .../Images/SingleFaviconDownloader.swift | 20 ++++++++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/Modules/Images/Sources/Images/FaviconDownloader.swift b/Modules/Images/Sources/Images/FaviconDownloader.swift index fb17f8ad9..86ec18784 100644 --- a/Modules/Images/Sources/Images/FaviconDownloader.swift +++ b/Modules/Images/Sources/Images/FaviconDownloader.swift @@ -160,13 +160,6 @@ extension Notification.Name { return } - // URL-level outcome runs before the homePageURL guard so we record it even when homePageURL is nil. - if let error = singleFaviconDownloader.error { - ImageDatabase.shared.recordFailure(url: singleFaviconDownloader.faviconURL, statusCode: error.statusCode) - } else if singleFaviconDownloader.iconImage != nil { - ImageDatabase.shared.clearFailure(url: singleFaviconDownloader.faviconURL) - } - guard let homePageURL = singleFaviconDownloader.homePageURL else { return } diff --git a/Modules/Images/Sources/Images/SingleFaviconDownloader.swift b/Modules/Images/Sources/Images/SingleFaviconDownloader.swift index 4d6d5a9c9..17b26194b 100644 --- a/Modules/Images/Sources/Images/SingleFaviconDownloader.swift +++ b/Modules/Images/Sources/Images/SingleFaviconDownloader.swift @@ -23,9 +23,6 @@ extension Notification.Name { public var iconImage: IconImage? - /// The persistent failure, if any. Nil after success or for transient failures. - public private(set) var error: ImageDownloadError? - private static let retryInterval: TimeInterval = 30 * 60 // 30 minutes private var lastDownloadAttemptDate: Date @@ -62,16 +59,15 @@ extension Notification.Name { private extension SingleFaviconDownloader { func findFavicon() async { - do throws(ImageDownloadError) { - let kind = ActivityKind.downloadFavicon(faviconURL: faviconURL) - let storedData = try await DownloadedImageCache.shared.imageData(for: faviconURL, downloadPriority: nil, checksForUpdates: true, activityOwner: .faviconDownloader, activityKind: kind, activityDetail: homePageURL) - guard let image = await Self.iconImage(storedData, maxPixelSize: RSImage.maxIconPixelSize) else { - throw ImageDownloadError(statusCode: nil, decodingFailed: true, isTransient: false) + let kind = ActivityKind.downloadFavicon(faviconURL: faviconURL) + if let storedData = try? await DownloadedImageCache.shared.imageData(for: faviconURL, downloadPriority: nil, checksForUpdates: true, activityOwner: .faviconDownloader, activityKind: kind, activityDetail: homePageURL) { + // DownloadedImageCache records download failures, but can’t know whether the data decodes as an icon. + if let image = await Self.iconImage(storedData, maxPixelSize: RSImage.maxIconPixelSize) { + iconImage = IconImage(image) + ImageDatabase.shared.clearFailure(url: faviconURL) + } else { + ImageDatabase.shared.recordFailure(url: faviconURL, statusCode: nil) } - iconImage = IconImage(image) - error = nil - } catch { - self.error = error.isTransient ? nil : error } postDidLoadFaviconNotification() }