cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/5] git commit: Make ResourcesLoader be able to delete files (as well as directories)
Date Tue, 20 May 2014 19:52:53 GMT
Make ResourcesLoader be able to delete files (as well as directories)


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/074d388a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/074d388a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/074d388a

Branch: refs/heads/master
Commit: 074d388a54ba6942fdbd5b8e9315d52cd8eca7bb
Parents: f205214
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue May 20 14:42:13 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue May 20 14:42:13 2014 -0400

----------------------------------------------------------------------
 www/cdvah/js/ResourcesLoader.js | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/074d388a/www/cdvah/js/ResourcesLoader.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/ResourcesLoader.js b/www/cdvah/js/ResourcesLoader.js
index 8a213d6..442c9c2 100644
--- a/www/cdvah/js/ResourcesLoader.js
+++ b/www/cdvah/js/ResourcesLoader.js
@@ -185,13 +185,19 @@
                 });
             },
 
-            deleteDirectory: function(url) {
+            delete: function(url) {
                 return resolveURL(url)
-                .then(function(dirEntry) {
+                .then(function(entry) {
                     var deferred = $q.defer();
-                    dirEntry.removeRecursively(deferred.resolve, function(error) {
-                        deferred.reject(new Error('There was an error deleting the directory:
' + url + ' ' + JSON.stringify(error)));
-                    });
+                    if (entry.removeRecursively) {
+                        entry.removeRecursively(deferred.resolve, function(error) {
+                            deferred.reject(new Error('There was an error deleting directory:
' + url + ' ' + JSON.stringify(error)));
+                        });
+                    } else {
+                        entry.remove(deferred.resolve, function(error) {
+                            deferred.reject(new Error('There was an error deleting file:
' + url + ' ' + JSON.stringify(error)));
+                        });
+                    }
                     return deferred.promise;
                 }, function() {});
             },


Mime
View raw message