Ben Copsey

Fail gracefully when attempting to download to an invalid local path

... ... @@ -2218,7 +2218,9 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
+ (int)uncompressZippedDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath
{
// Create an empty file at the destination path
[[NSFileManager defaultManager] createFileAtPath:destinationPath contents:[NSData data] attributes:nil];
if (![[NSFileManager defaultManager] createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) {
return 1;
}
// Get a FILE struct for the source file
NSFileHandle *inputFileHandle = [NSFileHandle fileHandleForReadingAtPath:sourcePath];
... ...
... ... @@ -879,6 +879,21 @@
GHAssertNotNil([request error],@"Failed to generate an authentication error");
}
- (void)testFetchToInvalidPath
{
// Test gzipped content
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request setDownloadDestinationPath:@"/an/invalid/location.html"];
[request start];
GHAssertNotNil([request error],@"Failed to generate an authentication when attempting to write to an invalid location");
//Test non-gzipped content
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/i/logo.png"]];
[request setDownloadDestinationPath:@"/an/invalid/location.png"];
[request start];
GHAssertNotNil([request error],@"Failed to generate an authentication when attempting to write to an invalid location");
}
@end
... ...