You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/10/25 03:26:22 UTC

[04/17] git commit: Delete manifest.json if it causes an exception

Delete manifest.json if it causes an exception


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/4c0ac66f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/4c0ac66f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/4c0ac66f

Branch: refs/heads/master
Commit: 4c0ac66f83a1eb5be9ce5c54b5f871b0273077a2
Parents: b0ec606
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 26 16:19:12 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:43:37 2014 -0400

----------------------------------------------------------------------
 www/cdvah/js/DirectoryManager.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/4c0ac66f/www/cdvah/js/DirectoryManager.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/DirectoryManager.js b/www/cdvah/js/DirectoryManager.js
index da39c82..15484e3 100644
--- a/www/cdvah/js/DirectoryManager.js
+++ b/www/cdvah/js/DirectoryManager.js
@@ -82,8 +82,15 @@
             }
             this._assetManifestEtag = Math.floor(Math.random() * 0xFFFFFFFF);
             this._lazyWriteAssetManifest();
+            var self = this;
             if (etag !== null && this.onFileAdded) {
-                return this.onFileAdded(relativePath, etag);
+                return this.onFileAdded(relativePath, etag)
+                .then(null, function(err) {
+                    // If there was an error with the file, delete it so that clients will
+                    // send it again.
+                    return self.deleteFile(relativePath)
+                    .then(function() { throw err; }, function() { throw err; });
+                });
             }
         };
 
@@ -133,10 +140,10 @@
         DirectoryManager.prototype.deleteFile = function(relativePath) {
             if (!this._assetManifest[relativePath]) {
                 console.warn('Tried to delete non-existing file: ' + relativePath);
-            } else {
-                this._updateManifest(relativePath, null);
-                return ResourcesLoader.delete(this.rootURL + relativePath);
+                return $q.when();
             }
+            this._updateManifest(relativePath, null);
+            return ResourcesLoader.delete(this.rootURL + relativePath);
         };
 
         return DirectoryManager;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org