From 009fdcd63933be426aa21d15357faa70402974e4 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Tue, 26 Sep 2023 11:52:41 +0200 Subject: [PATCH] Fix for crash on lazy compactMap unwrap --- Core/WebCacheManager.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/WebCacheManager.swift b/Core/WebCacheManager.swift index d9d9c0a69f..3444380821 100644 --- a/Core/WebCacheManager.swift +++ b/Core/WebCacheManager.swift @@ -263,7 +263,12 @@ public class WebCacheManager { .appendingPathComponent("WebKit/\(bundleID)/WebsiteData/ResourceLoadStatistics/observations.db") ] - return databaseURLs.lazy.compactMap({ try? DatabasePool(path: $0.absoluteString) }).first + guard let validURL = databaseURLs.first(where: { FileManager.default.fileExists(atPath: $0.path) }), + let pool = try? DatabasePool(path: validURL.absoluteString) else { + return nil + } + + return pool }