You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/02/11 00:23:15 UTC

[49/50] git commit: CB-5974: Use safe 'Compatibilty' mode by default

CB-5974: Use safe 'Compatibilty' mode by default

Only throw an exception and terminate the app on startup if an invalid value
is present in config.xml.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/3c0ba720
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/3c0ba720
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/3c0ba720

Branch: refs/heads/master
Commit: 3c0ba7208453f38e7b5d783e5868e892d614bfb3
Parents: d8c5e5d
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Feb 5 16:23:53 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Feb 5 16:23:53 2014 -0500

----------------------------------------------------------------------
 doc/index.md               | 6 ++++--
 src/android/FileUtils.java | 3 +++
 src/ios/CDVFile.m          | 8 +++++---
 3 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3c0ba720/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index dd36dc7..b0877c3 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -68,7 +68,8 @@ config.xml:
 
     <preference name="AndroidPersistentFileLocation" value="Compatibility" />
 
-Without this line, the File plugin will not initialize, and your application
+Without this line, the File plugin will use "Compatibility" as the default. If
+a preference tag is present, and is not one of these values, the application
 will not start.
 
 If your application has previously been shipped to users, using an older (pre-
@@ -114,7 +115,8 @@ add one of these two lines to config.xml:
 
     <preference name="iosPersistentFileLocation" value="Compatibility" />
 
-Without this line, the File plugin will not initialize, and your application
+Without this line, the File plugin will use "Compatibility" as the default. If
+a preference tag is present, and is not one of these values, the application
 will not start.
 
 If your application has previously been shipped to users, using an older (pre-

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3c0ba720/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 8e6646b..23496ca 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -104,6 +104,9 @@ public class FileUtils extends CordovaPlugin {
     	String packageName = activity.getPackageName();
     	
     	String location = activity.getIntent().getStringExtra("androidpersistentfilelocation");
+    	if (location == null) {
+    		location = "compatibility";
+    	}
     	if ("internal".equalsIgnoreCase(location)) {
     		persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/";
     		tempRoot = activity.getCacheDir().getAbsolutePath();

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3c0ba720/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index d07cc9c..39234e5 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -193,9 +193,11 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
             CDVViewController *vc = (CDVViewController *)_viewController;
             NSMutableDictionary *settings = vc.settings;
             location = [[settings objectForKey:@"iospersistentfilelocation"] lowercaseString];
-            NSAssert(
-                [location isEqualToString:@"library"] || [location isEqualToString:@"compatibility"],
-                @"File plugin configuration error: Please set iosPersistentFileLocation in config.xml to one of \"library\" (for new applications) or \"compatibility\" (for compatibility with previous versions)");
+        }
+        if (location == nil) {
+            // Compatibilty by default (if the config preference is not set, or
+            // if we're not embedded in a CDVViewController somehow.)
+            location = @"compatibility";
         }
 
         NSError *error;