From 674b55d480bd434c211e3faa493f659d0b2890e9 Mon Sep 17 00:00:00 2001 From: Alin Date: Thu, 11 Apr 2024 14:21:54 -0600 Subject: [PATCH] v3.4.2 --- Pearcleaner.xcodeproj/project.pbxproj | 8 +-- Pearcleaner/Logic/AppInfoFetch.swift | 2 +- Pearcleaner/Logic/AppPathsFetch.swift | 79 ++++++++++++++++++++------- Pearcleaner/Logic/Locations.swift | 1 + Pearcleaner/Logic/Utilities.swift | 11 ++++ 5 files changed, 75 insertions(+), 26 deletions(-) diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index 66f4729..b9e0e53 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -575,7 +575,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; @@ -593,7 +593,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.4.1; + MARKETING_VERSION = 3.4.2; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -610,7 +610,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BK8443AXLU; @@ -628,7 +628,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.4.1; + MARKETING_VERSION = 3.4.2; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Pearcleaner/Logic/AppInfoFetch.swift b/Pearcleaner/Logic/AppInfoFetch.swift index 77ca97d..fe65cc2 100644 --- a/Pearcleaner/Logic/AppInfoFetch.swift +++ b/Pearcleaner/Logic/AppInfoFetch.swift @@ -50,7 +50,7 @@ class AppInfoFetcher { // ?? bundle.infoDictionary?["CFBundleName"] as? String // ?? path.deletingPathExtension().lastPathComponent - let appName = path.deletingPathExtension().lastPathComponent.capitalized + let appName = path.deletingPathExtension().lastPathComponent.capitalizingFirstLetter() let appVersion = bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? bundle.infoDictionary?["CFBundleVersion"] as? String diff --git a/Pearcleaner/Logic/AppPathsFetch.swift b/Pearcleaner/Logic/AppPathsFetch.swift index c42601f..b5b556f 100644 --- a/Pearcleaner/Logic/AppPathsFetch.swift +++ b/Pearcleaner/Logic/AppPathsFetch.swift @@ -82,14 +82,6 @@ class AppPathFinder { } } } -// if FileManager.default.fileExists(atPath: itemURL.path, isDirectory: &isDirectory), -// isDirectory.boolValue, -// !shouldSkipItem(itemL, at: itemURL), -// specificCondition(itemL: itemL, itemURL: itemURL) { -// collectionAccessQueue.sync { -// self.collection.append(itemURL) -// } -// } } } } @@ -114,16 +106,11 @@ class AppPathFinder { let itemURL = URL(fileURLWithPath: location).appendingPathComponent(item) let itemL = item.replacingOccurrences(of: ".", with: "").replacingOccurrences(of: " ", with: "").lowercased() - var isDirectory: ObjCBool = false - if FileManager.default.fileExists(atPath: itemURL.path, isDirectory: &isDirectory), - !isDirectory.boolValue, + if FileManager.default.fileExists(atPath: itemURL.path), !shouldSkipItem(itemL, at: itemURL), specificCondition(itemL: itemL, itemURL: itemURL) { collectionAccessQueue.sync { - let parentDirectory = itemURL.deletingLastPathComponent() - if !self.collection.contains(parentDirectory) { - self.collection.append(itemURL) - } + self.collection.append(itemURL) } } } @@ -137,7 +124,7 @@ class AppPathFinder { collectionAccessQueue.sync { containsItem = self.collection.contains(itemURL) } - return itemL.hasPrefix("comapple") && !["comappleconfigurator", "comappledt", "comappleiwork"].contains(where: itemL.hasPrefix) || containsItem || !isSupportedFileType(at: itemURL.path) + return itemL.hasPrefix("comapple") && !["comappleconfigurator", "comappledt", "comappleiwork", "comapplesfsymbols", "comappletestflight"].contains(where: itemL.hasPrefix) || containsItem || !isSupportedFileType(at: itemURL.path) } @@ -176,8 +163,30 @@ class AppPathFinder { } if bundleIdentifierL.contains("combravebrowser") { - // Include items for Zoom that are not similar to the app name and/or bundle id - if itemL.contains("bravesoftware") { + // Include items for Brave that are not similar to the app name and/or bundle id + if itemL.contains("brave") { + return true + } + } + + if bundleIdentifierL.contains("comgooglechrome") { + // Include items for Chrome that are not similar to the app name and/or bundle id + if (itemL.contains("google") && !itemL.contains("iterm")) || (itemL.contains("chrome") && !itemL.contains("chromefeaturestate")) { + return true + } + } + + if bundleIdentifierL.contains("commicrosoftedgemac") { + // Include items for Edge that are not similar to the app name and/or bundle id + let exclusions = ["vscode","rdc","appcenter","office","oneauth"] + if itemL.contains("microsoft") && !exclusions.contains(where: itemL.contains) { + return true + } + } + + if bundleIdentifierL.contains("orgmozillafirefox") { + // Include items for Firefox that are not similar to the app name and/or bundle id + if itemL.contains("mozilla") { return true } } @@ -196,6 +205,22 @@ class AppPathFinder { } } + + if bundleIdentifierL.contains("comfacebookarchondeveloperid") { + // Include items for FB Messenger + if itemL.contains("archonloginhelper") { + return true + } + } + + if bundleIdentifierL.contains("euexelbanstats") { + // Include items for Stats that are not similar to the app name and/or bundle id + if itemL.contains("video") { + return false + } + } + + if self.appInfo.webApp { return itemL.contains(bundleIdentifierL) } @@ -271,9 +296,21 @@ class AppPathFinder { tempCollection.append(contentsOf: groupContainers) tempCollection.append(contentsOf: outliers) - // Continue with the sorted collection - let sortedCollection = tempCollection.sorted(by: { $0.absoluteString < $1.absoluteString }) - self.handlePostProcessing(sortedCollection: sortedCollection) + // Sort and standardize URLs to ensure consistent comparisons + let sortedCollection = tempCollection.map { $0.standardizedFileURL }.sorted(by: { $0.path < $1.path }) + var filteredCollection: [URL] = [] + var previousUrl: URL? + for url in sortedCollection { + if let previousUrl = previousUrl, url.path.hasPrefix(previousUrl.path + "/") { + // Current URL is a subdirectory of the previous one, so skip it + continue + } + // This URL is not a subdirectory of the previous one, so keep it and set it as the previous URL + filteredCollection.append(url) + previousUrl = url + } + + self.handlePostProcessing(sortedCollection: filteredCollection) } } diff --git a/Pearcleaner/Logic/Locations.swift b/Pearcleaner/Logic/Locations.swift index 9e859a9..c0307e9 100644 --- a/Pearcleaner/Logic/Locations.swift +++ b/Pearcleaner/Logic/Locations.swift @@ -34,6 +34,7 @@ class Locations: ObservableObject { "\(home)/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments", "\(home)/Library/Containers", "\(home)/Library/Caches", + "\(home)/Library/Group Containers", "\(home)/Library/HTTPStorages", "\(home)/Library/Internet Plug-Ins", "\(home)/Library/LaunchAgents", diff --git a/Pearcleaner/Logic/Utilities.swift b/Pearcleaner/Logic/Utilities.swift index 45a2aa0..d6fb3bc 100644 --- a/Pearcleaner/Logic/Utilities.swift +++ b/Pearcleaner/Logic/Utilities.swift @@ -428,6 +428,17 @@ extension String { } } +// --- Capitalize first letter of string only +extension String { + func capitalizingFirstLetter() -> String { + return prefix(1).capitalized + dropFirst() + } + + mutating func capitalizeFirstLetter() { + self = self.capitalizingFirstLetter() + } +} + // --- Trash Relationship --- extension FileManager {