Update directory locations for webstorage on ios6. Fix issue with copyTo not working if dest dir didn't exist.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/3b006538 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/3b006538 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/3b006538 Branch: refs/heads/master Commit: 3b006538edcbe122bac9d90f913ba0a9f94857cb Parents: e6788ba Author: Michal Mocny <mmo...@gmail.com> Authored: Thu Aug 23 10:29:34 2012 -0400 Committer: Michal Mocny <mmo...@gmail.com> Committed: Thu Aug 23 10:29:34 2012 -0400 ---------------------------------------------------------------------- CordovaLib/Classes/CDVLocalStorage.m | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/3b006538/CordovaLib/Classes/CDVLocalStorage.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m index 9f51f18..2200761 100644 --- a/CordovaLib/Classes/CDVLocalStorage.m +++ b/CordovaLib/Classes/CDVLocalStorage.m @@ -72,7 +72,7 @@ //////////// LOCALSTORAGE NSString *original = [[appLibraryFolder stringByAppendingPathComponent: - (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/LocalStorage"] + (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/LocalStorage"] stringByAppendingPathComponent:@"file__0.localstorage"]; NSString *backup = [backupsFolder stringByAppendingPathComponent:@"localstorage.appdata.db"]; @@ -87,7 +87,7 @@ //////////// WEBSQL MAIN DB original = [[appLibraryFolder stringByAppendingPathComponent: - (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/Databases"] + (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/Databases"] stringByAppendingPathComponent:@"Databases.db"]; backup = [backupsFolder stringByAppendingPathComponent:@"websqlmain.appdata.db"]; @@ -102,7 +102,7 @@ //////////// WEBSQL DATABASES original = [[appLibraryFolder stringByAppendingPathComponent: - (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/Databases"] + (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/Databases"] stringByAppendingPathComponent:@"file__0"]; backup = [backupsFolder stringByAppendingPathComponent:@"websqldbs.appdata.db"]; @@ -150,7 +150,12 @@ // remove the dest if (destExists && ![fileManager removeItemAtPath:dest error:error]) { return NO; - } + } + + // create path to dest + if (!destExists && ![fileManager createDirectoryAtPath:[dest stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:error]) { + return NO; + } // copy src to dest if ([fileManager copyItemAtPath:src toPath:dest error:error]) { @@ -321,7 +326,7 @@ if ([manager fileExistsAtPath:info.backup]) { [self copyFrom:info.backup to:info.original error:nil]; [manager removeItemAtPath:info.backup error:nil]; - NSLog(@"Removing old webstorage backup locations: %@", info.backup); + NSLog(@"Restoring, then removing old webstorage backup. From: '%@' To: '%@'.", info.backup, info.original); } } }