Ben Copsey

Merge pull request #211 from christophercotton/master

Cache Error with downloadDestinationPath, Not storing downloaded data
@@ -159,9 +159,14 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -159,9 +159,14 @@ static NSString *permanentCacheFolder = @"PermanentStore";
159 159
160 if ([request responseData]) { 160 if ([request responseData]) {
161 [[request responseData] writeToFile:dataPath atomically:NO]; 161 [[request responseData] writeToFile:dataPath atomically:NO];
162 - } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) { 162 + } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
163 NSError *error = nil; 163 NSError *error = nil;
164 - [[[[NSFileManager alloc] init] autorelease] copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error]; 164 + NSFileManager* manager = [[NSFileManager alloc] init];
  165 + if ([manager fileExistsAtPath:dataPath]) {
  166 + [manager removeItemAtPath:dataPath error:&error];
  167 + }
  168 + [manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
  169 + [manager release];
165 } 170 }
166 [[self accessLock] unlock]; 171 [[self accessLock] unlock];
167 } 172 }