mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Resolve symlinks when finding a matching running application path
This fixes issues where Sparkle may think an application has already terminated when placed in a directory that has symlinks (such as /tmp/)
This commit is contained in:
1 parent
11cbecbeaa
commit
69db74bc36
1 file changed
+5
-4
Vendored
+5
-4
@@ -35,10 +35,11 @@
|
||||
|
||||
+ (NSRunningApplication *)runningApplicationWithBundle:(NSBundle *)bundle
|
||||
{
|
||||
NSString *bundlePath = bundle.bundlePath;
|
||||
// Resolve symlinks otherwise when we compare file paths, we may not realize two paths that are represented differently are the same
|
||||
NSArray<NSString *> *bundlePathComponents = bundle.bundlePath.stringByResolvingSymlinksInPath.pathComponents;
|
||||
NSString *bundleIdentifier = bundle.bundleIdentifier;
|
||||
|
||||
if (bundleIdentifier != nil && bundlePath != nil) {
|
||||
if (bundleIdentifier != nil && bundlePathComponents != nil) {
|
||||
NSArray *runningApplications =
|
||||
(bundleIdentifier != nil) ?
|
||||
[NSRunningApplication runningApplicationsWithBundleIdentifier:bundleIdentifier] :
|
||||
@@ -46,8 +47,8 @@
|
||||
|
||||
for (NSRunningApplication *runningApplication in runningApplications) {
|
||||
// Comparing the URLs hasn't worked well for me in practice, so I'm comparing the file paths instead
|
||||
NSString *candidatePath = runningApplication.bundleURL.path;
|
||||
if (candidatePath != nil && [candidatePath isEqualToString:bundlePath]) {
|
||||
NSString *candidatePath = runningApplication.bundleURL.URLByResolvingSymlinksInPath.path;
|
||||
if (candidatePath != nil && [candidatePath.pathComponents isEqualToArray:bundlePathComponents]) {
|
||||
return runningApplication;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user