Reputation: 22992
We are getting an error when trying to delete a folder on startup. We are removing a folder placed in documents used to store cache-data. Any idea why it is crashing?
0 libsystem_kernel.dylib 0x364b62d0 __unlink + 8
1 libsystem_kernel.dylib 0x364b46a6 unlink + 2
2 libremovefile.dylib 0x313099c8 __removefile_process_file + 232
3 libremovefile.dylib 0x31309a50 __removefile_tree_walker + 100
4 libremovefile.dylib 0x313090f4 removefile + 88
5 Foundation 0x3156c11a -[NSFilesystemItemRemoveOperation main] + 138
6 Foundation 0x31551d14 -[__NSOperationInternal start] + 652
7 Foundation 0x31551a78 -[NSOperation start] + 16
8 Foundation 0x3156bfda -[NSFileManager removeItemAtPath:error:] + 46
9 VG 0x0004f030 +[VGFileManager removeOldCacheFolder] + 319536
10 VG 0x00003e1c -[VGAppDelegate application:didFinishLaunchingWithOptions:] + 11804
11 UIKit 0x31de481a -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 766
12 UIKit 0x31ddeb5e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
13 UIKit 0x31db37d0 -[UIApplication handleEvent:withNewEvent:] + 1108
14 UIKit 0x31db320e -[UIApplication sendEvent:] + 38
15 UIKit 0x31db2c4c _UIApplicationHandleEvent + 5084
16 GraphicsServices 0x34720e70 PurpleEventCallback + 660
17 CoreFoundation 0x30ba5a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
18 CoreFoundation 0x30ba7838 __CFRunLoopDoSource1 + 160
19 CoreFoundation 0x30ba8606 __CFRunLoopRun + 514
20 CoreFoundation 0x30b38ebc CFRunLoopRunSpecific + 224
21 CoreFoundation 0x30b38dc4 CFRunLoopRunInMode + 52
22 UIKit 0x31dddd42 -[UIApplication _run] + 366
23 UIKit 0x31ddb800 UIApplicationMain + 664
24 VG 0x0000bd96 0x1000 + 44438
25 VG 0x00003990 0x1000 + 10640
This is the function called on "9".
+ (void)removeOldCacheFolder {
BOOL oldCacheFolderRemoved = [[NSUserDefaults standardUserDefaults] boolForKey:kVGFileCacheFolder_1_2];
if(!oldCacheFolderRemoved){
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; //Get documents folder
NSString *cacheDirectory = [documentsDirectory stringByAppendingPathComponent:kVGFileCacheFolder_1_2];
if ([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectory]) {
NSError *error = nil;
if (!([[NSFileManager defaultManager] removeItemAtPath:cacheDirectory error:&error])) {
ELog(@"Unresolved error %@, %@", error, [error userInfo]);
}
else{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kVGFileCacheFolder_1_2];
}
}
}
BOOL oldSQLFileDeleted = [[NSUserDefaults standardUserDefaults] boolForKey:kVGFileDb_1_3];
if(!oldSQLFileDeleted){
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; //Get documents folder
NSString *sqlFile = [documentsDirectory stringByAppendingPathComponent:kVGFileDb_1_3];
if ([[NSFileManager defaultManager] fileExistsAtPath:sqlFile]) {
NSError *error = nil;
if (!([[NSFileManager defaultManager] removeItemAtPath:sqlFile error:&error])) {
ELog(@"Unresolved error %@, %@", error, [error userInfo]);
}
else{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kVGFileDb_1_3];
}
}
}
}
EDIT: Just discovered this process can take 2 minutes...
Upvotes: 0
Views: 2042
Reputation: 8069
There is a special caches folder that iOS maintains - it's contents is not backed up whereas you data will be backed up when syncing.
NSString *tmpDir = NSTemporaryDirectory();
You trimmed of the exception type from you dump. You could perhaps learn something about the crash from the exception type and code.
I read through the version 1.2 section of the code and honestly it looks just fine. Check your define for kVGFileCacheFolder_1_2 - I assume something like @"file.dat" which is also fine.
Check that the file is closed and there is no other ongoing operations on the file.
Upvotes: 1
Reputation: 22992
Maybe we're getting killed by the iOS watchdog, any app that takes too long to launch gets terminated. Could it be a too time consuming process?
Upvotes: 2