Ben Copsey

Fix clearing cached data in clearCachedResponsesForStoragePolicy: (closes gh-114)

Tweak tests that rely on invalid urls to make them work to make them more reliable
@@ -385,13 +385,10 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -385,13 +385,10 @@ static NSString *permanentCacheFolder = @"PermanentStore";
385 [NSException raise:@"FailedToTraverseCacheDirectory" format:@"Listing cache directory failed at path '%@'",path]; 385 [NSException raise:@"FailedToTraverseCacheDirectory" format:@"Listing cache directory failed at path '%@'",path];
386 } 386 }
387 for (NSString *file in cacheFiles) { 387 for (NSString *file in cacheFiles) {
388 - NSString *extension = [file pathExtension]; 388 + [fileManager removeItemAtPath:[path stringByAppendingPathComponent:file] error:&error];
389 - if ([extension isEqualToString:@"cacheddata"] || [extension isEqualToString:@"cachedheaders"]) { 389 + if (error) {
390 - [fileManager removeItemAtPath:[path stringByAppendingPathComponent:file] error:&error]; 390 + [[self accessLock] unlock];
391 - if (error) { 391 + [NSException raise:@"FailedToRemoveCacheFile" format:@"Failed to remove cached data at path '%@'",path];
392 - [[self accessLock] unlock];  
393 - [NSException raise:@"FailedToRemoveCacheFile" format:@"Failed to remove cached data at path '%@'",path];  
394 - }  
395 } 392 }
396 } 393 }
397 [[self accessLock] unlock]; 394 [[self accessLock] unlock];
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 #import "ASIDataCompressor.h" 24 #import "ASIDataCompressor.h"
25 25
26 // Automatically set on build 26 // Automatically set on build
27 -NSString *ASIHTTPRequestVersion = @"v1.8-23 2010-12-13"; 27 +NSString *ASIHTTPRequestVersion = @"v1.8-25 2010-12-15";
28 28
29 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; 29 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
30 30
@@ -128,12 +128,12 @@ @@ -128,12 +128,12 @@
128 128
129 // Test ASIFallbackToCacheIfLoadFailsCachePolicy 129 // Test ASIFallbackToCacheIfLoadFailsCachePolicy
130 // Store something in the cache 130 // Store something in the cache
131 - [request setURL:[NSURL URLWithString:@"http://inva.lid"]]; 131 + [request setURL:[NSURL URLWithString:@"http://"]];
132 [request setResponseHeaders:[NSDictionary dictionaryWithObject:@"test" forKey:@"test"]]; 132 [request setResponseHeaders:[NSDictionary dictionaryWithObject:@"test" forKey:@"test"]];
133 [request setRawResponseData:(NSMutableData *)[@"test" dataUsingEncoding:NSUTF8StringEncoding]]; 133 [request setRawResponseData:(NSMutableData *)[@"test" dataUsingEncoding:NSUTF8StringEncoding]];
134 [[ASIDownloadCache sharedCache] storeResponseForRequest:request maxAge:0]; 134 [[ASIDownloadCache sharedCache] storeResponseForRequest:request maxAge:0];
135 135
136 - request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://inva.lid"]]; 136 + request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://"]];
137 [request setCachePolicy:ASIFallbackToCacheIfLoadFailsCachePolicy]; 137 [request setCachePolicy:ASIFallbackToCacheIfLoadFailsCachePolicy];
138 [request startSynchronous]; 138 [request startSynchronous];
139 139
@@ -1097,7 +1097,7 @@ IMPORTANT @@ -1097,7 +1097,7 @@ IMPORTANT
1097 [queue setShowAccurateProgress:YES]; 1097 [queue setShowAccurateProgress:YES];
1098 1098
1099 [queue setDelegate:self]; 1099 [queue setDelegate:self];
1100 - ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://999.123"]]; 1100 + ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://"]];
1101 [request setDelegate:self]; 1101 [request setDelegate:self];
1102 [request setDidFailSelector:@selector(HEADFail:)]; 1102 [request setDidFailSelector:@selector(HEADFail:)];
1103 [queue addOperation:request]; 1103 [queue addOperation:request];