Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with long delays when changing enabled filter lists (#24330) (Uplift to 1.68.x) #24538

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ import WebKit
guard
let folderURL = FileManager.default.getOrCreateFolder(
name: "custom_rules",
location: .applicationDirectory
location: .applicationSupportDirectory
)
else {
throw ResourceFileError.failedToCreateCacheFolder
Expand Down Expand Up @@ -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
}
}
Loading