From 49f717c1b1bb98101297b2b80dfcf06d8612a72f Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Tue, 13 May 2008 22:25:56 -0700 Subject: [PATCH] Fixes #230173 by removing partially downloaded files on download error. Sparkle no longer leaks the NSURLDownload if the download fails. --- SUBasicUpdateDriver.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index a1d2f105..7b128293 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -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]; }