Skip to content

Commit

Permalink
Cache would not store the downloaded data if the cached file already …
Browse files Browse the repository at this point in the history
…existed. Remove old one first
  • Loading branch information
christophercotton committed Jun 17, 2011
1 parent 2980421 commit 22f1b31
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Classes/ASIDownloadCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,14 @@ - (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval

if ([request responseData]) {
[[request responseData] writeToFile:dataPath atomically:NO];
} else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
} else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {
NSError *error = nil;
[[[[NSFileManager alloc] init] autorelease] copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
NSFileManager* manager = [[NSFileManager alloc] init];
if ([manager fileExistsAtPath:dataPath]) {
[manager removeItemAtPath:dataPath error:&error];
}
[manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
[manager release];
}
[[self accessLock] unlock];
}
Expand Down

0 comments on commit 22f1b31

Please sign in to comment.