tarkit
tarkit copied to clipboard
call method:"decompressFileAtPath:toPath:error:" crash
when call the method and give a error parameters will crash.
like this:
NSError *decompressError = nil;
[DCTar decompressFileAtPath:strPath1 toPath:strPath2 error:&decompressError];
you can try it.
Ok, this doesn't give us anything to go off. Can you provide the crash you are getting? What is strPath1
and strPath2
?
The code like this is ok:
[QFZIP decompressFileAtPath:strPath1 toPath:strPath2 error:nil];
and the code like this will crash:
NSError *decompressError = nil;
[QFZIP decompressFileAtPath:strPath1 toPath:strPath2 error:&decompressError];
Just give a error variable as the parameter.
@daltoniam
strPath1 = @"/var/mobile/Containers/Data/Application/A94B4EAC-5875-47AB-AC21-8437E72C6B78/Documents/Data/DownloadData.tar.gz"
strPath2 = @"/var/mobile/Containers/Data/Application/A94B4EAC-5875-47AB-AC21-8437E72C6B78/Documents/Data"
and crash info is:
Incident Identifier: 760F6AD2-6BC7-4E4C-A802-8FC60312ADF5
CrashReporter Key: 6971d8ae264d1f2f519b9ac7bbd6b1dba7a9a8a2
Hardware Model: iPhone7,2
OS Version: iPhone OS 8.3 (12F70)
Kernel version: Darwin Kernel Version 14.0.0: Sun Mar 29 19:42:54 PDT 2015; root:xnu-2784.20.34~2/RELEASE_ARM64_T7000
Date: 2016-01-26 17:19:01 +0800
Exception Code: 0xd1510c8d
Reason: Step count has rolled back!!
Thermal data unavailable
Frontmost process PID: 3194
Frontmost process PID: 54
Stackshot trace buffer size too small, trying again with 524288 bytes.
Jetsam Level: 0
Free Pages: 18232
Active Pages: 134789
Inactive Pages: 13616
Purgeable Pages: 796
Wired Pages: 52444
Speculative Pages: 17507
Throttled Pages: 0
File-backed Pages: 83496
Compressions: 92138
Decompressions: 13727
Compressor Size: 16028
Busy Buffer Count: 1
Pages Wanted: 0
Pages Reclaimed: 0
Hmm interesting. Do you have a stack trace? Not sure why providing a error would cause a crash, I don't see anything off hand that would cause that.
looks like not stack trace, I used NSURLSession to download the gzip file from server, and then decompress it, the stack trace just like this:


I got the same problem.
The error
will trigger the crash.
Here is my stack trace.
Hi, I guess this error
passed down in a autoreleasepool
maybe the reason.
https://github.com/daltoniam/tarkit/blob/master/DCTar.m#L315
I changed it to nill and it will stop crashing.
if(size == 0) {
[@"" writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
@jinzhubaofu let me try.
@jinzhubaofu it's helpful to me!
would be better to change that to
if(size == 0) {
NSError *writeError;
BOOL ret = [@"" writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&writeError];
if (!ret) {
NSLog(@"UNTAR - error during creating a directrory for a file - %@", writeError);
}
}
for anyone coming to this from swift. The error param is automatically 'scooped' into the system, so you can't just set it to nil.
I ended up just creating an objective C helper
//DCTarHelper.h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface DCTarHelper : NSObject
+(BOOL)decompressFileAtPath:(NSString*)filePath toPath:(NSString*)path;
@end
NS_ASSUME_NONNULL_END
//DCTarHelper.m
#import "DCTarHelper.h"
#import <tarkit/DCTar.h>
@implementation DCTarHelper
+(BOOL)decompressFileAtPath:(NSString*)filePath toPath:(NSString*)path {
return [DCTar decompressFileAtPath:filePath toPath:path error:nil];
}
@end
which you can then call from Swift
DCTarHelper.decompressFile(atPath: source, toPath: destination)