Cache would not store the downloaded data if the cached file already existed. Remove old one first
Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -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 | } |
-
Please register or login to post a comment