diff --git a/SUConstants.h b/SUConstants.h index 4ef1ebb4..b1d46c26 100644 --- a/SUConstants.h +++ b/SUConstants.h @@ -24,7 +24,7 @@ // If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it // in place, giving you an app named 1.1b4 that is actually 1.2. Turn the // following on to always reset the name back to "MyApp": -#define NORMALIZE_INSTALLED_APP_NAME 1 +#define NORMALIZE_INSTALLED_APP_NAME 0 #define TRY_TO_APPEND_VERSION_NUMBER 1 diff --git a/SUHost.m b/SUHost.m index 4ecfa462..a73295fc 100644 --- a/SUHost.m +++ b/SUHost.m @@ -63,10 +63,12 @@ - (NSString *)installationPath { #if NORMALIZE_INSTALLED_APP_NAME - return [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]; -#else - return [bundle bundlePath]; + // 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:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]; + if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) + return normalizedAppPath; #endif + return [bundle bundlePath]; } - (NSString *)name