This commit is contained in:
Alin
2024-01-22 16:26:25 -07:00
parent d0a36f8695
commit ab7477de44
4 changed files with 59 additions and 21 deletions
+4 -4
View File
@@ -543,7 +543,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 14;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BK8443AXLU;
@@ -561,7 +561,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.2;
MARKETING_VERSION = 2.3;
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -578,7 +578,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 14;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BK8443AXLU;
@@ -596,7 +596,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.2;
MARKETING_VERSION = 2.3;
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
+1 -2
View File
@@ -35,10 +35,9 @@ struct Locations {
"\(home)/Library/Application Support/CrashReporter",
"\(home)/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments",
"\(home)/Library/Containers",
"\(home)/Library/Group Containers",
// "\(home)/Library/Group Containers", // This is now handled by the function getGroupContainers()
"\(home)/Library/Caches",
"\(home)/Library/HTTPStorages",
"\(home)/Library/Group Containers",
"\(home)/Library/Internet Plug-Ins",
"\(home)/Library/LaunchAgents",
"\(home)/Library/Logs",
+53 -15
View File
@@ -56,7 +56,7 @@ func getApplications() -> (systemApps: [URL], userApps: [URL]) {
print("Error: \(error)")
}
}
// Collect system applications
collectAppPaths(at: systemAppsPath, isSystem: true)
@@ -300,8 +300,9 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
}
dispatchGroup.enter() // Enter the dispatch group
do {
let contents = try fileManager.contentsOfDirectory(atPath: location)
for item in contents {
@@ -340,11 +341,14 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
// collection.append(itemURL)
// }
// Catch MS Office files since they have many random folder names and very short names
} else if itemL.contains("office") || itemL.contains("oneauth") || itemL.suffix(2).contains("ms") || itemL.contains("onenote") {
if itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 4 && itemL.contains(nameL)) {
collection.append(itemURL)
}
} else {
}
// This is now covered by the group container logic, not needed anymore
// else if itemL.contains("office") || itemL.contains("oneauth") || itemL.suffix(2).contains("ms") || itemL.contains("onenote") {
// if itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 4 && itemL.contains(nameL)) {
// collection.append(itemURL)
// }
// }
else {
if itemL.contains(bundleIdentifierL) || itemL.contains(bundle) || (nameL.count > 3 && itemL.contains(nameL)) {
collection.append(itemURL)
}
@@ -357,20 +361,54 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
}
dispatchGroup.leave() // Leave the dispatch group
dispatchGroup.notify(queue: .main) {
updateOnMain {
appState.paths = collection
appState.selectedItems = Set(collection)
}
}
}
// Append group containers
let groupContainers = getGroupContainers(bundleURL: appState.appInfo.path)
collection.append(contentsOf: groupContainers)
let sortedCollection = collection.sorted(by: { $0.absoluteString < $1.absoluteString })
// Save to appState
dispatchGroup.notify(queue: .main) {
updateOnMain {
appState.paths = sortedCollection
appState.selectedItems = Set(sortedCollection)
}
}
}
}
func getGroupContainers(bundleURL: URL) -> [URL] {
var staticCode: SecStaticCode?
guard SecStaticCodeCreateWithPath(bundleURL as CFURL, [], &staticCode) == errSecSuccess else {
return []
}
var signingInformation: CFDictionary?
let status = SecCodeCopySigningInformation(staticCode!, SecCSFlags(), &signingInformation)
if status != errSecSuccess {
print("Failed to copy signing information. Status: \(status)")
return []
}
guard let topDict = signingInformation as? [String: Any],
let entitlementsDict = topDict["entitlements-dict"] as? [String: Any],
let appGroups = entitlementsDict["com.apple.security.application-groups"] as? [String] else {
// print("No application groups to extract from entitlements for this app.")
return []
}
let groupContainersPath = appGroups.map { URL(fileURLWithPath: "\(home)/Library/Group Containers/" + $0) }
return groupContainersPath
}
// Move files to trash using applescript/Finder so it asks for user password if needed
+1
View File
@@ -43,6 +43,7 @@ struct MiniMode: View {
FilesView(showPopover: $showPopover, search: $search)
.id(appState.appInfo.id)
}
.interactiveDismissDisabled()
.background(
Rectangle()
.fill(Color("pop"))