From 67ebc6ff74b82a9dde4b4f528a3fb1bb64006167 Mon Sep 17 00:00:00 2001 From: Dmytro Tretiakov Date: Tue, 6 Aug 2013 15:16:29 +0300 Subject: [PATCH] Adds removing old data before downloading new one via XPC. --- Downloading XPC Service/SUXPCURLDownload.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Downloading XPC Service/SUXPCURLDownload.m b/Downloading XPC Service/SUXPCURLDownload.m index af651a5b..bfba4545 100644 --- a/Downloading XPC Service/SUXPCURLDownload.m +++ b/Downloading XPC Service/SUXPCURLDownload.m @@ -76,6 +76,12 @@ static NSString * const kSUFetchFolderName = @"fetch.XXXXXXXX"; NSURL *tempFolder = [NSURL fileURLWithPath:NSTemporaryDirectory()]; NSString *tempFileTemplate = [[tempFolder URLByAppendingPathComponent:kSUFetchFolderName] path]; NSString *tempFilePath = [tempFileTemplate stringByAppendingPathComponent:[_destination lastPathComponent]]; + + if ([[NSFileManager defaultManager] fileExistsAtPath:tempFilePath]) + { + [[NSFileManager defaultManager] removeItemAtPath:tempFilePath error:nil]; + [[NSFileManager defaultManager] createDirectoryAtPath:tempFilePath withIntermediateDirectories:YES attributes:nil error:nil]; + } _connectionDestination = [tempFilePath copy]; NSData *requestData = [NSKeyedArchiver archivedDataWithRootObject:urlRequest];