Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
#32 Crash at startup when too much files ?
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Dec 10, 2014
1 parent 2e68452 commit 955d100
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ It's a screenshot of the [demo app](demo/index.html).
## 3. Installation

```
$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-wkwebview
$ cordova plugin add https://github.com/Telerik-Verified-Plugins/WKWebView
$ cordova prepare
```

No need for anything else - you can now open the project in XCode 6 if you like.

## 4. Changelog
* __0.2.7__ Cut app startup time in half - not noticable unless you have a lot of files in your app, see #32
* __0.2.6__ `Config.xml` settings like `MediaPlaybackRequiresUserAction` (autoplay HTML 5 video) are now supported, see #25.
* __0.2.5__ Fixed a script error for Cordova 3.5.0 and lower, see #17.
* __0.2.4__ Compatibility with the `device` plugin on Cordova 3.5.0 and lower, see #17.
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="com.telerik.plugins.wkwebview"
version="0.2.6">
version="0.2.7">

<name>WKWebView Polyfill</name>

Expand Down
32 changes: 3 additions & 29 deletions src/ios/MyMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "ReroutingUIWebView.h"

@interface CDVViewController ()
@property (nonatomic, readwrite, retain) NSArray *startupPluginNames;
@property (nonatomic, readwrite, retain) NSArray *startupPluginNames;
@end

@interface MyMainViewController () {
Expand Down Expand Up @@ -135,21 +135,9 @@ - (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasi
}
return NO;
}

// generate unique filepath in temp directory
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
CFRelease(uuidString);
CFRelease(uuidRef);


BOOL destExists = [fileManager fileExistsAtPath:dest];

// backup the dest
if (destExists && ![fileManager copyItemAtPath:dest toPath:tempBackup error:error]) {
return NO;
}

// remove the dest
if (destExists && ![fileManager removeItemAtPath:dest error:error]) {
return NO;
Expand All @@ -161,21 +149,7 @@ - (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasi
}

// copy src to dest
if ([fileManager copyItemAtPath:src toPath:dest error:error]) {
// success - cleanup - delete the backup to the dest
if ([fileManager fileExistsAtPath:tempBackup]) {
[fileManager removeItemAtPath:tempBackup error:error];
}
return YES;
} else {
// failure - we restore the temp backup file to dest
[fileManager copyItemAtPath:tempBackup toPath:dest error:error];
// cleanup - delete the backup to the dest
if ([fileManager fileExistsAtPath:tempBackup]) {
[fileManager removeItemAtPath:tempBackup error:error];
}
return NO;
}
return [fileManager copyItemAtPath:src toPath:dest error:error];
}

- (void)viewDidLoad
Expand Down

0 comments on commit 955d100

Please sign in to comment.