mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Move installationPath out from SUHost
It's not too relevant to SUHost, and mostly relevant to the installer. Plus its output can depend on whether a certain file exists on the system.
This commit is contained in:
1 parent
6de75413e8
commit
9bb87b2018
7 files changed
+25
-23
No files matched your search
Vendored
+19
-3
@@ -355,7 +355,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
NSError *installerError = nil;
|
||||
id <SUInstaller> installer = [SUInstaller installerForHost:self.host updateDirectory:self.installationData.updateDirectoryPath versionComparator:[SUStandardVersionComparator defaultComparator] error:&installerError];
|
||||
id <SUInstaller> installer = [SUInstaller installerForHost:self.host installationPath:[self installationPath] updateDirectory:self.installationData.updateDirectoryPath versionComparator:[SUStandardVersionComparator defaultComparator] error:&installerError];
|
||||
|
||||
if (installer == nil) {
|
||||
SULog(@"Error: Failed to create installer instance with error: %@", installerError);
|
||||
@@ -395,6 +395,22 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
});
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
{
|
||||
NSBundle *bundle = self.host.bundle;
|
||||
assert(bundle != nil);
|
||||
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:normalizedAppPath]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
}
|
||||
return [bundle bundlePath];
|
||||
}
|
||||
|
||||
- (void)performStage2InstallationIfNeeded
|
||||
{
|
||||
#warning this test should be async?
|
||||
@@ -406,7 +422,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
// Predict if an admin prompt is needed
|
||||
// If it is, we should activate our app so that the auth prompt will be active
|
||||
// (Note it's more efficient/simpler to predict rather than trying, seeing if we fail, notifying, and re-trying)
|
||||
NSString *installationPath = self.host.installationPath;
|
||||
NSString *installationPath = [self installationPath];
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:installationPath]) {
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
@@ -476,7 +492,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString *installationPath = [self.host.installationPath copy];
|
||||
NSString *installationPath = [self installationPath];
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
NSString *pathToRelaunch = nil;
|
||||
|
||||
Vendored
-1
@@ -13,7 +13,6 @@
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||
@property (readonly, copy) NSString *bundlePath;
|
||||
@property (readonly, copy) NSString *installationPath;
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
@property (readonly, copy) NSString *displayVersion;
|
||||
|
||||
Vendored
+1
-14
@@ -60,26 +60,13 @@
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self bundlePath]]; }
|
||||
|
||||
- (NSString *)bundlePath
|
||||
{
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
{
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:normalizedAppPath]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
}
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *__nonnull)name
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUInstaller : NSObject
|
||||
|
||||
+ (nullable id<SUInstaller>)installerForHost:(SUHost *)host updateDirectory:(NSString *)updateDirectory versionComparator:(id <SUVersionComparison>)comparator error:(NSError **)error;
|
||||
+ (nullable id<SUInstaller>)installerForHost:(SUHost *)host installationPath:(NSString *)installationPath updateDirectory:(NSString *)updateDirectory versionComparator:(id <SUVersionComparison>)comparator error:(NSError **)error;
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr;
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -109,7 +109,7 @@
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (nullable id<SUInstaller>)installerForHost:(SUHost *)host updateDirectory:(NSString *)updateDirectory versionComparator:(id <SUVersionComparison>)comparator error:(NSError * __autoreleasing *)error
|
||||
+ (nullable id<SUInstaller>)installerForHost:(SUHost *)host installationPath:(NSString *)installationPath updateDirectory:(NSString *)updateDirectory versionComparator:(id <SUVersionComparison>)comparator error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
@@ -128,7 +128,7 @@
|
||||
} else if (isPackage) {
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
} else {
|
||||
installer = [[SUPlainInstaller alloc] initWithHost:host applicationPath:newDownloadPath installationPath:host.installationPath versionComparator:comparator];
|
||||
installer = [[SUPlainInstaller alloc] initWithHost:host applicationPath:newDownloadPath installationPath:installationPath versionComparator:comparator];
|
||||
}
|
||||
return installer;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -40,7 +40,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
|
||||
Vendored
+1
-1
@@ -119,7 +119,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)startUpdateCycle
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user