[Pkg-mozext-commits] [greasemonkey] 04/19: Let "download complete" callbacks handle any potential cleanup.

David Prévot taffit at moszumanska.debian.org
Sat Mar 21 02:50:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 8b2baa15f5a0c1772ea3e94b3cdeb201cd1cf447
Author: Ventero <ventero at ventero.de>
Date:   Tue Sep 16 03:50:27 2014 +0200

    Let "download complete" callbacks handle any potential cleanup.
    
    Fixes #1998.
---
 modules/remoteScript.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/remoteScript.js b/modules/remoteScript.js
index 682d242..0aa0c50 100644
--- a/modules/remoteScript.js
+++ b/modules/remoteScript.js
@@ -166,7 +166,9 @@ DownloadListener.prototype = {
         return;  // Non-http channel?  Ignore.
       }
       if (this._htmlTypeRegex.test(aRequest.contentType)) {
-        this._completionCallback(aRequest, false, 'script');
+        // Cancel this request immediately and let onStopRequest handle the
+        // cleanup for everything else.
+        aRequest.cancel(Components.results.NS_BINDING_ABORTED);
       }
     }
   },
@@ -205,11 +207,10 @@ DownloadListener.prototype = {
     if (error && this._errorsAreFatal) {
       errorMessage = stringBundle.GetStringFromName('error.downloadingUrl')
           + '\n' + this._uri.spec + '\n\n' + errorMessage;
-      this._remoteScript.cleanup(errorMessage);
     }
 
     this._progressCallback(aRequest, 1);
-    this._completionCallback(aRequest, !error);
+    this._completionCallback(aRequest, !error, errorMessage);
   },
 
   // nsIProgressEventSink
@@ -528,11 +529,12 @@ RemoteScript.prototype._downloadDependencies = function(aCompletionCallback) {
   var file = GM_util.getTempFile(this._tempDir, filenameFromUri(uri));
   dependency.setFilename(file);
 
-  function dependencyDownloadComplete(aChannel, aSuccess) {
+  function dependencyDownloadComplete(aChannel, aSuccess, aErrorMessage) {
     if (!aSuccess) {
       if (dependency instanceof ScriptIcon) {
         // Ignore the failure to download the icon.
       } else {
+        this.cleanup(aErrorMessage);
         aCompletionCallback(aSuccess, 'dependency');
         return;
       }
@@ -601,7 +603,8 @@ RemoteScript.prototype._downloadFileProgress = function(
 };
 
 RemoteScript.prototype._downloadScriptCb = function(
-    aCompletionCallback, aChannel, aSuccess) {
+    aCompletionCallback, aChannel, aSuccess, aErrorMessage) {
+
   if (aSuccess) {
     // At this point downloading the script itself is definitely done.
 
@@ -630,7 +633,7 @@ RemoteScript.prototype._downloadScriptCb = function(
       return aCompletionCallback(false, 'script');
     }
   } else {
-    this.cleanup();
+    this.cleanup(aErrorMessage);
   }
   aCompletionCallback(aSuccess, 'script');
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list