mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 10:48:52 +00:00
updates
This commit is contained in:
@@ -19,7 +19,7 @@ class AppState: ObservableObject
|
||||
@Published var zombieFile: ZombieFile
|
||||
@Published var sortedApps: [AppInfo] = []
|
||||
@Published var selectedItems = Set<URL>()
|
||||
@Published var selectedZombieItems = Set<URL>()
|
||||
// @Published var selectedZombieItems = Set<URL>()
|
||||
@Published var alertType = AlertType.off
|
||||
@Published var currentView = CurrentDetailsView.empty
|
||||
@Published var showAlert: Bool = false
|
||||
|
||||
@@ -99,7 +99,7 @@ class Locations: ObservableObject {
|
||||
"/Library/PrivilegedHelperTools",
|
||||
"/private/var/db/receipts",
|
||||
cacheDir,
|
||||
tempDir
|
||||
// tempDir // Stop listing these files as there's a ton of them and they get cleaned up by the OS anyways
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func listAppSupportDirectories() -> [String] {
|
||||
|
||||
|
||||
// Load app paths on launch
|
||||
func reversePreloader(allApps: [AppInfo], appState: AppState, locations: Locations, reverseAddon: Bool = false, completion: @escaping () -> Void = {}) {
|
||||
func reversePreloader(allApps: [AppInfo], appState: AppState, locations: Locations, fsm: FolderSettingsManager, reverseAddon: Bool = false, completion: @escaping () -> Void = {}) {
|
||||
let dispatchGroup = DispatchGroup()
|
||||
appState.appInfoStore.removeAll()
|
||||
|
||||
@@ -127,7 +127,7 @@ func reversePreloader(allApps: [AppInfo], appState: AppState, locations: Locatio
|
||||
func checkAllAppsProcessed(retryCount: Int = 0, maxRetry: Int = 120) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
if appState.appInfoStore.count == allApps.count {
|
||||
ReversePathsSearcher(appState: appState, locations: locations).reversePathsSearch() {
|
||||
ReversePathsSearcher(appState: appState, locations: locations, fsm: fsm).reversePathsSearch() {
|
||||
updateOnMain {
|
||||
appState.showProgress = false
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import AppKit
|
||||
class ReversePathsSearcher {
|
||||
private let appState: AppState
|
||||
private let locations: Locations
|
||||
private let fsm: FolderSettingsManager
|
||||
private let fileManager = FileManager.default
|
||||
private var collection: [URL] = []
|
||||
private var fileSize: [URL: Int64] = [:]
|
||||
@@ -18,9 +19,10 @@ class ReversePathsSearcher {
|
||||
private var fileIcon: [URL: NSImage?] = [:]
|
||||
private let dispatchGroup = DispatchGroup()
|
||||
|
||||
init(appState: AppState, locations: Locations) {
|
||||
init(appState: AppState, locations: Locations, fsm: FolderSettingsManager) {
|
||||
self.appState = appState
|
||||
self.locations = locations
|
||||
self.fsm = fsm
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +66,11 @@ class ReversePathsSearcher {
|
||||
let formattedItemName = itemName.pearFormat()
|
||||
let itemPath = itemURL.path.pearFormat()
|
||||
let itemLastPathComponent = itemURL.lastPathComponent.pearFormat()
|
||||
let exclusionList = fsm.fileFolderPathsZ.map { $0.pearFormat() }
|
||||
|
||||
if exclusionList.contains(itemPath) || itemPath.contains("dsstore") || itemPath.contains("daemonnameoridentifierhere") {
|
||||
return
|
||||
}
|
||||
|
||||
guard !skipReverse.contains(where: { formattedItemName.contains($0) }),
|
||||
!allPaths.contains(where: { $0 == itemPath || $0.hasSuffix("/\(itemLastPathComponent)") }),
|
||||
|
||||
@@ -476,7 +476,8 @@ extension Int {
|
||||
// --- Extend String to remove periods, spaces and lowercase the string
|
||||
extension String {
|
||||
func pearFormat() -> String {
|
||||
return self.replacingOccurrences(of: ".", with: "").replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "-", with: "").lowercased()
|
||||
// Remove all non-alphanumeric characters using regular expression and convert to lowercase
|
||||
return self.replacingOccurrences(of: "[^a-zA-Z0-9]", with: "", options: .regularExpression).lowercased()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user