Fixes #230173 by removing partially downloaded files on download error.

Sparkle no longer leaks the NSURLDownload if the download fails.
This commit is contained in:
Andy Matuschak committed 2008-05-13 22:25:56 -07:00
1 parent 7c709cb9fe
commit 49f717c1b1
1 file changed
+4 -3
+4 -3
View File
@@ -110,7 +110,6 @@
{
// Okay, something's really broken with /tmp
[download cancel];
[download release]; download = nil;
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir] forKey:NSLocalizedDescriptionKey]]];
}
@@ -120,13 +119,14 @@
- (void)downloadDidFinish:(NSURLDownload *)d
{
[download release];
download = nil;
[self extractUpdate];
}
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
// Get rid of what we've downloaded so far, if anything.
if (downloadPath != nil)
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[downloadPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[downloadPath lastPathComponent]] tag:NULL];
[self abortUpdateWithError:error];
}
@@ -213,6 +213,7 @@
[hostBundle release];
[downloadPath release];
[unarchiver release];
[download release];
[super dealloc];
}