From d0a6c699daa10e55352dadc6b0f757401fe806fb Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Thu, 1 Jun 2017 16:55:52 -0500 Subject: [PATCH] Don't assume that the progress block exists (the parameter is nullable) --- Sparkle/SUPlainInstaller.m | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 2f326767..a7fd0281 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -72,7 +72,9 @@ return NO; } - progress(1/10.0); + if (progress) { + progress(1/10.0); + } SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath]; @@ -85,7 +87,9 @@ return NO; } - progress(2/10.0); + if (progress) { + progress(2/10.0); + } // Move the new app to our temporary directory NSString *newURLLastPathComponent = newURL.lastPathComponent; @@ -96,7 +100,9 @@ return NO; } - progress(3/10.0); + if (progress) { + progress(3/10.0); + } // Release our new app from quarantine, fix its owner and group IDs, and update its modification time while it's at our temporary destination // We must leave moving the app to its destination as the final step in installing it, so that @@ -108,7 +114,9 @@ SULog(SULogLevelError, @"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError); } - progress(4/10.0); + if (progress) { + progress(4/10.0); + } NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath]; if (oldURL == nil) { @@ -127,15 +135,18 @@ return NO; } - - progress(5/10.0); + if (progress) { + progress(5/10.0); + } if (![fileManager updateModificationAndAccessTimeOfItemAtURL:newTempURL error:error]) { // Not a fatal error, but a pretty unfortunate one SULog(SULogLevelError, @"Failed to update modification and access time of new app at %@", newTempURL.path); } - progress(6/10.0); + if (progress) { + progress(6/10.0); + } // Decide on a destination name we should use for the older app when we move it around the file system NSString *oldDestinationName = nil; @@ -159,7 +170,9 @@ return NO; } - progress(7/10.0); + if (progress) { + progress(7/10.0); + } // Move the old app to the temporary directory NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; @@ -173,7 +186,9 @@ return NO; } - progress(8/10.0); + if (progress) { + progress(8/10.0); + } // Move the new app to its final destination if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { @@ -189,7 +204,9 @@ return NO; } - progress(9/10.0); + if (progress) { + progress(9/10.0); + } // From here on out, we don't really need to bring up authorization if we haven't done so prior SUFileManager *constrainedFileManager = [fileManager fileManagerByPreservingAuthorizationRights]; @@ -198,7 +215,9 @@ [constrainedFileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; [constrainedFileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - progress(10/10.0); + if (progress) { + progress(10/10.0); + } return YES; }