From fa8aaced551e91fc3c591cf45e20f2fccccc4c9e Mon Sep 17 00:00:00 2001 From: Uli Kusterer Date: Mon, 14 Dec 2009 22:30:56 +0100 Subject: [PATCH] Make sure we also delete the temp dir when the user clicks "cancel" during the download. --- SUUIBasedUpdateDriver.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index b5552546..f85cb371 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -118,11 +118,16 @@ [statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self _humanReadableSizeFromDouble:[statusController progressValue]]]]; } -- (IBAction)cancelDownload:sender +- (IBAction)cancelDownload: (id)sender { if (download) [download cancel]; [self abortUpdate]; + if (tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here. + { + if( ![[NSFileManager defaultManager] removeFileAtPath: tempDir handler: nil] ) + [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tempDir stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[tempDir lastPathComponent]] tag:NULL]; + } } - (void)extractUpdate