This commit is contained in:
Alin
2024-02-05 11:34:46 -07:00
parent 589eccdef3
commit e734df7f70
2 changed files with 37 additions and 33 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 = 15;
CURRENT_PROJECT_VERSION = 16;
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.4;
MARKETING_VERSION = 2.5;
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 = 15;
CURRENT_PROJECT_VERSION = 16;
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.4;
MARKETING_VERSION = 2.5;
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
+33 -29
View File
@@ -73,12 +73,23 @@ func getApplications() -> (systemApps: [URL], userApps: [URL]) {
func getAppInfo(atPath path: URL) -> AppInfo? {
if let bundle = Bundle(url: path) {
if let bundleIdentifier = bundle.bundleIdentifier,
let appVersion = bundle.infoDictionary?["CFBundleShortVersionString"] as? String,
var appIconFileName = bundle.infoDictionary?["CFBundleIconFile"] as? String {
var appVersion = "0.0.0"
var appIcon: NSImage?
var appName: String?
var webApp: Bool?
if let shortVersion = bundle.infoDictionary?["CFBundleShortVersionString"] as? String {
appVersion = shortVersion
} else {
if let bundleVersion = bundle.infoDictionary?["CFBundleVersion"] as? String {
appVersion = bundleVersion
} else {
print("Failed to retrieve bundle version")
}
}
if let localizedName = bundle.localizedInfoDictionary?[kCFBundleNameKey as String] as? String {
appName = localizedName
} else if let bundleName = bundle.infoDictionary?["CFBundleName"] as? String {
@@ -125,21 +136,27 @@ func getAppInfo(atPath path: URL) -> AppInfo? {
return AppInfo(id: UUID(), path: path, bundleIdentifier: bundleIdentifier, appName: appName ?? "", appVersion: appVersion, appIcon: appIcon, webApp: webApp ?? false, wrapped: false)
} else {
let wrapperURL = path.appendingPathComponent("Wrapper")//.appendingPathComponent(path.lastPathComponent)
do {
let contents = try FileManager.default.contentsOfDirectory(at: wrapperURL, includingPropertiesForKeys: nil, options: [])
let appFiles = contents.filter { $0.pathExtension == "app" }
let wrapperURL = path.appendingPathComponent("Wrapper")
if let firstAppFile = appFiles.first {
let fullPath = wrapperURL.appendingPathComponent(firstAppFile.lastPathComponent)
if let wrappedAppInfo = getWrappedAppInfo(atPath: fullPath) {
return wrappedAppInfo
// Check that file path exists, exit if not
if FileManager.default.fileExists(atPath: wrapperURL.path) {
do {
let contents = try FileManager.default.contentsOfDirectory(at: wrapperURL, includingPropertiesForKeys: nil, options: [])
let appFiles = contents.filter { $0.pathExtension == "app" }
if let firstAppFile = appFiles.first {
let fullPath = wrapperURL.appendingPathComponent(firstAppFile.lastPathComponent)
if let wrappedAppInfo = getWrappedAppInfo(atPath: fullPath) {
return wrappedAppInfo
}
} else {
print("No .app files found in the 'Wrapper' directory.")
}
} else {
print("No .app files found in the 'Wrapper' directory.")
} catch {
print("Error reading contents of 'Wrapper' directory: \(error.localizedDescription)")
}
} catch {
print("Error reading contents of 'Wrapper' directory: \(error.localizedDescription)")
} else {
print("Error: 'Wrapper' directory not found at path: \(wrapperURL.path)")
}
}
@@ -291,6 +308,7 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
}
let nameL = appInfo.appName.pearFormat()
let nameP = appInfo.path.lastPathComponent.replacingOccurrences(of: ".app", with: "")
let bundleIdentifierL = appInfo.bundleIdentifier.pearFormat()
let locations = Locations()
@@ -334,22 +352,8 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
if itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 4 && itemL.contains(nameL)) {
collection.append(itemURL)
}
// This causes too many issues, disabling this filter for now /////////////////////////////////
// Catch Logitech files since Logi is part of word login and can return random files
// } else if itemL.contains("logi") && !itemL.contains("login") {
// if itemL.contains(bundleComponents[weirdFormatBundle ? 0 : 1]) || itemL.contains(bundle) || itemL.contains(bundleIdentifierL) || (nameL.count > 3 && itemL.contains(nameL)) {
// collection.append(itemURL)
// }
// Catch MS Office files since they have many random folder names and very short names
}
// 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)) {
} else {
if itemL.contains(bundleIdentifierL) || itemL.contains(bundle) || (nameL.count > 3 && itemL.contains(nameL) || (nameP.count > 3 && itemL.contains(nameP))) {
collection.append(itemURL)
}
}