Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Cache Error with downloadDestinationPath, Not storing downloaded data #211

Merged
merged 1 commit into from

3 participants

@christophercotton

I fixed a problem I noticed. If you use the cache to store files and you are storing using a downloadDestinationPath, the cache does not correctly copy over the new data.

The next time you download that url, it will return the old data. The fix is to delete the file before copying over the old one.

@danielr

+1
Please integrate this fix in your next release. I had exactly the same issue. For now, I'm going to patch our local source of ASIHTTPRequest, but it would be nice if this patch wouldn't be gone after updating the next time.

@pokeb pokeb merged commit e7fff59 into from
@pokeb
Owner

Merged now, many thanks!

@pokeb pokeb referenced this pull request from a commit
@pokeb Add test to ensure gh-211 stays fixed 6eac3fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 17, 2011
  1. @christophercotton
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 Classes/ASIDownloadCache.m
View
9 Classes/ASIDownloadCache.m
@@ -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];
}
Something went wrong with that request. Please try again.