diff --git a/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift b/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift index 9e59df718824..41f9d6e553c5 100644 --- a/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift +++ b/ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockGroupsManager.swift @@ -275,7 +275,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( @@ -523,7 +527,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 } @@ -536,7 +539,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 74d76a2d4496..cd298336e68b 100644 --- a/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift +++ b/ios/brave-ios/Sources/Brave/WebFilters/CustomFilterListStorage.swift @@ -170,7 +170,7 @@ import WebKit guard let folderURL = FileManager.default.getOrCreateFolder( name: "custom_rules", - location: .applicationDirectory + location: .applicationSupportDirectory ) else { throw ResourceFileError.failedToCreateCacheFolder @@ -203,14 +203,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 } }