Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused temporaryName: parameter and supporting code. #585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sparkle/SUBasicUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];

if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
self.relaunchPath = targetPath;
} else {
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
Expand Down
3 changes: 1 addition & 2 deletions Sparkle/SUPlainInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ + (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSStrin
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
NSString *oldPath = [host bundlePath];
NSString *tempName = [self temporaryNameForPath:[host installationPath]];

BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error];
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error];

if (result) {
if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) {
Expand Down
3 changes: 1 addition & 2 deletions Sparkle/SUPlainInstallerInternals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#import "SUPlainInstaller.h"

@interface SUPlainInstaller (Internals)
+ (NSString *)temporaryNameForPath:(NSString *)path;
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp appendVersion:(BOOL)a error:(NSError **)error;
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)a error:(NSError **)error;
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)a;
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error;
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
Expand Down
24 changes: 1 addition & 23 deletions Sparkle/SUPlainInstallerInternals.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza

@implementation SUPlainInstaller (Internals)

+ (NSString *)temporaryNameForPath:(NSString *)path
{
// Let's try to read the version number so the filename will be more meaningful.
NSString *postFix;
NSString *version;
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
}
else
postFix = @"old";
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
// Now let's make sure we get a unique path.
unsigned int cnt = 2;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
return [tempDir lastPathComponent];
}

+ (NSString *)_temporaryCopyNameForPath:(NSString *)path appendVersion:(BOOL)appendVersion didFindTrash:(BOOL *)outDidFindTrash
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
Expand Down Expand Up @@ -464,7 +442,7 @@ + (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)appendVersion
}
}

+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error
{
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
OSStatus err;
Expand Down