From b088cda5a5ff342ab03204efdade087a28f89405 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Thu, 30 Jan 2020 15:41:00 -0600 Subject: [PATCH 1/2] Fix homePageURLsWithNoFaviconURLCache --- Shared/Favicons/FaviconDownloader.swift | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Shared/Favicons/FaviconDownloader.swift b/Shared/Favicons/FaviconDownloader.swift index eee115711..ccba7c6bb 100644 --- a/Shared/Favicons/FaviconDownloader.swift +++ b/Shared/Favicons/FaviconDownloader.swift @@ -131,20 +131,12 @@ final class FaviconDownloader { } findFaviconURLs(with: url) { (faviconURLs) in - var hasIcons = false - if let faviconURLs = faviconURLs { if let firstIconURL = faviconURLs.first { - hasIcons = true let _ = self.favicon(with: firstIconURL, homePageURL: url) self.remainingFaviconURLs[url] = faviconURLs.dropFirst() } } - - if (!hasIcons) { - self.homePageURLsWithNoFaviconURLCache.insert(url) - self.homePageURLsWithNoFaviconURLCacheDirty = true - } } return nil @@ -167,6 +159,8 @@ final class FaviconDownloader { remainingFaviconURLs[homePageURL] = faviconURLs.dropFirst(); } else { remainingFaviconURLs[homePageURL] = nil + self.homePageURLsWithNoFaviconURLCache.insert(homePageURL) + self.homePageURLsWithNoFaviconURLCacheDirty = true } } return From 97049be067fdee54078ff36b0e42f2ab8ceefd51 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Thu, 30 Jan 2020 16:02:20 -0600 Subject: [PATCH 2/2] Only add to the no-favicons cache if the only icon was the defaulted favicon.ico --- Shared/Favicons/FaviconDownloader.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Shared/Favicons/FaviconDownloader.swift b/Shared/Favicons/FaviconDownloader.swift index ccba7c6bb..447012cd6 100644 --- a/Shared/Favicons/FaviconDownloader.swift +++ b/Shared/Favicons/FaviconDownloader.swift @@ -24,6 +24,7 @@ final class FaviconDownloader { private let diskCache: BinaryDiskCache private var singleFaviconDownloaderCache = [String: SingleFaviconDownloader]() // faviconURL: SingleFaviconDownloader private var remainingFaviconURLs = [String: ArraySlice]() // homePageURL: array of faviconURLs that haven't been checked yet + private var currentHomePageHasOnlyFaviconICO = false private var homePageToFaviconURLCache = [String: String]() //homePageURL: faviconURL private var homePageToFaviconURLCachePath: String @@ -132,6 +133,8 @@ final class FaviconDownloader { findFaviconURLs(with: url) { (faviconURLs) in if let faviconURLs = faviconURLs { + self.currentHomePageHasOnlyFaviconICO = faviconURLs.count == 1 + if let firstIconURL = faviconURLs.first { let _ = self.favicon(with: firstIconURL, homePageURL: url) self.remainingFaviconURLs[url] = faviconURLs.dropFirst() @@ -159,8 +162,11 @@ final class FaviconDownloader { remainingFaviconURLs[homePageURL] = faviconURLs.dropFirst(); } else { remainingFaviconURLs[homePageURL] = nil - self.homePageURLsWithNoFaviconURLCache.insert(homePageURL) - self.homePageURLsWithNoFaviconURLCacheDirty = true + + if currentHomePageHasOnlyFaviconICO { + self.homePageURLsWithNoFaviconURLCache.insert(homePageURL) + self.homePageURLsWithNoFaviconURLCacheDirty = true + } } } return