diff --git a/Sparkle/SUCoreBasedUpdateDriver.m b/Sparkle/SUCoreBasedUpdateDriver.m index 78ca2246..f2d40f8f 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.m +++ b/Sparkle/SUCoreBasedUpdateDriver.m @@ -47,6 +47,7 @@ // If we support sandboxing this component in the future, it is important to note this may return a different path // For this reason, this method should not be a part of SUHost because its behavior depends on what kind of process it's being invoked from +#warning kind of duplicated code from SUUpdateDownloader ?? + (NSString *)sparkleCachePathForHost:(SUHost *)host { NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); @@ -65,7 +66,7 @@ } cachePath = [cachePath stringByAppendingPathComponent:name]; - cachePath = [cachePath stringByAppendingPathComponent:@"Sparkle"]; + cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER]; return cachePath; } diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 94bbbdc6..c70d6c3a 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -63,7 +63,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; assert(bundleIdentifier != nil); // Create a directory that'll be used for our web server listing - NSURL *serverDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; + NSURL *serverDirectoryURL = [[cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier] URLByAppendingPathComponent:@"ServerData"]; if ([serverDirectoryURL checkResourceIsReachableAndReturnError:nil]) { NSError *removeServerDirectoryError = nil; diff --git a/Tests/SUCodeSigningVerifierTest.m b/Tests/SUCodeSigningVerifierTest.m index 5b20983d..dd80a8a0 100644 --- a/Tests/SUCodeSigningVerifierTest.m +++ b/Tests/SUCodeSigningVerifierTest.m @@ -68,13 +68,8 @@ [super tearDown]; if (self.notSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.notSignedAppPath error:nil]; - } - if (self.validSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.validSignedAppPath error:nil]; - } - if (self.invalidSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.invalidSignedAppPath error:nil]; + NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent]; + [[NSFileManager defaultManager] removeItemAtPath:tempDir error:nil]; } } diff --git a/UpdateDownloader/SUUpdateDownloader.m b/UpdateDownloader/SUUpdateDownloader.m index 4d8c1c1e..40f23bed 100644 --- a/UpdateDownloader/SUUpdateDownloader.m +++ b/UpdateDownloader/SUUpdateDownloader.m @@ -45,16 +45,16 @@ - (void)startDownloadWithRequest:(NSURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename completion:(void (^)(BOOL success, NSError * _Nullable error))completionBlock { dispatch_async(dispatch_get_main_queue(), ^{ + // Remove our old caches path so we don't start accumulating files in there + NSString *cachePath = [[self class] sparkleCachePathForBundleIdentifier:bundleIdentifier]; + if ([[NSFileManager defaultManager] fileExistsAtPath:cachePath]) { + [[NSFileManager defaultManager] removeItemAtPath:cachePath error:NULL]; + } + self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self]; self.desiredFilename = desiredFilename; self.bundleIdentifier = bundleIdentifier; self.completionBlock = completionBlock; - - // Remove our old caches path so we don't start accumulating files in there - NSString *cachePath = [[self class] sparkleCachePathForBundleIdentifier:self.bundleIdentifier]; - if ([[NSFileManager defaultManager] fileExistsAtPath:cachePath]) { - [[NSFileManager defaultManager] removeItemAtPath:cachePath error:NULL]; - } }); } @@ -80,7 +80,7 @@ NSURL *cacheURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:NULL]; assert(cacheURL != nil); - return [[[cacheURL URLByAppendingPathComponent:bundleIdentifier] URLByAppendingPathComponent:@"Sparkle"] path]; + return [[[cacheURL URLByAppendingPathComponent:bundleIdentifier] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER] path]; } - (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name