From 7c60734bcc78b2aad539507dda540e7b1144eda2 Mon Sep 17 00:00:00 2001 From: Nick Jensen Date: Tue, 15 Dec 2015 15:16:02 +0100 Subject: [PATCH] error properly when crc check fails --- SSZipArchive/SSZipArchive.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index 08348df..0413993 100755 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -325,7 +325,8 @@ crc_ret = unzCloseCurrentFile( zip ); if (crc_ret == UNZ_CRCERROR) { //CRC ERROR - return NO; + success = NO; + break; } ret = unzGoToNextFile( zip ); @@ -375,9 +376,19 @@ [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; }