Christopher Cotton

Cache would not store the downloaded data if the cached file already existed. Remove old one first

@@ -185,7 +185,12 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -185,7 +185,12 @@ static NSString *permanentCacheFolder = @"PermanentStore";
185 [[request responseData] writeToFile:dataPath atomically:NO]; 185 [[request responseData] writeToFile:dataPath atomically:NO];
186 } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) { 186 } else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
187 NSError *error = nil; 187 NSError *error = nil;
188 - [[[[NSFileManager alloc] init] autorelease] copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error]; 188 + NSFileManager* manager = [[NSFileManager alloc] init];
  189 + if ([manager fileExistsAtPath:dataPath]) {
  190 + [manager removeItemAtPath:dataPath error:&error];
  191 + }
  192 + [manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
  193 + [manager release];
189 } 194 }
190 [[self accessLock] unlock]; 195 [[self accessLock] unlock];
191 } 196 }