Merge pull request #211 from christophercotton/master
Cache Error with downloadDestinationPath, Not storing downloaded data
Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -161,7 +161,12 @@ static NSString *permanentCacheFolder = @"PermanentStore"; | @@ -161,7 +161,12 @@ static NSString *permanentCacheFolder = @"PermanentStore"; | ||
| 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 | } |
-
Please register or login to post a comment