Skip to content

Commit

Permalink
Merge pull request ZipArchive#221 from wooga/master
Browse files Browse the repository at this point in the history
error properly when crc check fails
  • Loading branch information
jhudsonWA committed Dec 15, 2015
2 parents 578a157 + 7c60734 commit 7ee91f6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions SSZipArchive/SSZipArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ + (BOOL)unzipFileAtPath:(NSString *)path
crc_ret = unzCloseCurrentFile( zip );
if (crc_ret == UNZ_CRCERROR) {
//CRC ERROR
return NO;
success = NO;
break;
}
ret = unzGoToNextFile( zip );

Expand Down Expand Up @@ -375,9 +376,19 @@ + (BOOL)unzipFileAtPath:(NSString *)path
[delegate zipArchiveProgressEvent:fileSize total:fileSize];
}

NSError *retErr = nil;
if (crc_ret == UNZ_CRCERROR)
{
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"crc check failed for file"};
retErr = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-3 userInfo:userInfo];
}
if (error)
{
*error = retErr;
}
if (completionHandler)
{
completionHandler(path, YES, nil);
completionHandler(path, success, retErr);
}
return success;
}
Expand Down

0 comments on commit 7ee91f6

Please sign in to comment.