diff --git a/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift b/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift index 619ca41db240..7c037b8a7ebb 100644 --- a/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift +++ b/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift @@ -86,7 +86,7 @@ import os await ContentBlockerManager.GenericBlocklistType.allCases.asyncConcurrentForEach { genericType in let blocklistType = ContentBlockerManager.BlocklistType.generic(genericType) - var missingModes = await self.contentBlockerManager.missingModes( + let missingModes = await self.contentBlockerManager.missingModes( for: blocklistType, version: genericType.version ) @@ -302,7 +302,11 @@ import os func compileEngineIfFilesAreReady(for engineType: GroupedAdBlockEngine.EngineType) { let manager = self.getManager(for: engineType) let enabledSources = sourceProvider.enabledSources(for: engineType) - guard manager.checkHasAllInfo(for: enabledSources) else { return } + let availableSources = manager.compilableFiles(for: enabledSources) + .map({ $0.filterListInfo.source }) + guard enabledSources.allSatisfy({ availableSources.contains($0) }) else { + return + } Task { await manager.compileImmediatelyIfNeeded( @@ -608,7 +612,6 @@ extension AdBlockEngineManager.FileInfo { var enabledSources: [GroupedAdBlockEngine.Source] { var enabledSources = FilterListStorage.shared.enabledSources enabledSources.append(contentsOf: CustomFilterListStorage.shared.enabledSources) - enabledSources.append(contentsOf: [.filterListText]) return enabledSources } @@ -621,7 +624,6 @@ extension AdBlockEngineManager.FileInfo { case .aggressive: var sources = FilterListStorage.shared.sources(for: engineType) sources.append(contentsOf: CustomFilterListStorage.shared.allSources) - sources.append(contentsOf: [.filterListText]) return sources case .standard: return FilterListStorage.shared.sources(for: engineType) diff --git a/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift b/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift index f22454287680..dfc772fd7ce4 100644 --- a/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift +++ b/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift @@ -172,7 +172,7 @@ import WebKit guard let folderURL = FileManager.default.getOrCreateFolder( name: "custom_rules", - location: .applicationDirectory + location: .applicationSupportDirectory ) else { throw ResourceFileError.failedToCreateCacheFolder @@ -205,14 +205,20 @@ import WebKit extension CustomFilterListStorage { /// Gives us source representations of all the enabled custom filter lists @MainActor var enabledSources: [GroupedAdBlockEngine.Source] { - return + var sources = filterListsURLs .filter(\.setting.isEnabled) .map(\.setting.engineSource) + if (try? self.savedCustomRulesFileURL()) == nil { return sources } + sources.append(.filterListText) + return sources } /// Gives us source representations of all the custom filter lists @MainActor var allSources: [GroupedAdBlockEngine.Source] { - return filterListsURLs.map(\.setting.engineSource) + var sources = filterListsURLs.map(\.setting.engineSource) + if (try? self.savedCustomRulesFileURL()) == nil { return sources } + sources.append(.filterListText) + return sources } }