Adds removing old data before downloading new one via XPC.

This commit is contained in:
Dmytro Tretiakov committed 2013-08-06 15:16:29 +03:00
1 parent 1e14f7d7b6
commit 67ebc6ff74
1 file changed
+6
@@ -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];