Bug 735206 - Fix incorrect URL insertion on chained uploads. r=bienvenu.
authorMike Conley <mconley@mozilla.com>
Tue, 13 Mar 2012 12:01:35 -0400
changeset 11094 b3d3b3afb05c2cb942acb56b31655be1da4f738d
parent 11093 e197041b44253e37d7ad0d4e5cb10eb5a8dc49e4
child 11095 3d368e502399d8b6ecfc936e5847d88dadb564d7
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs735206
Bug 735206 - Fix incorrect URL insertion on chained uploads. r=bienvenu.
mail/components/cloudfile/nsDropbox.js
mail/components/cloudfile/nsYouSendIt.js
--- a/mail/components/cloudfile/nsDropbox.js
+++ b/mail/components/cloudfile/nsDropbox.js
@@ -75,18 +75,18 @@ nsDropbox.prototype = {
   _uploadingFile : null,
   _uploader : null,
   _lastErrorStatus : 0,
   _lastErrorText : "",
   _maxFileSize : kMaxFileSize,
   _availableStorage : -1,
   _fileSpaceUsed : -1,
   _uploads: [],
-  _urlsForFiles : [],
-  _uploadInfo : [], // upload info keyed on aFiles.
+  _urlsForFiles : {},
+  _uploadInfo : {}, // upload info keyed on aFiles.
 
   /**
    * Initialize this instance of nsDropbox, setting the accountKey.
    *
    * @param aAccountKey the account key to initialize this provider with
    */
   init: function nsDropbox_init(aAccountKey) {
     this._accountKey = aAccountKey;
@@ -284,17 +284,17 @@ nsDropbox.prototype = {
   },
 
   /**
    * For some nsILocalFile, return the associated sharing URL.
    *
    * @param aFile the nsILocalFile to retrieve the URL for
    */
   urlForFile: function nsDropbox_urlForFile(aFile) {
-    return this._urlsForFiles[aFile];
+    return this._urlsForFiles[aFile.path];
   },
 
   /**
    * Updates the profile information for the account associated with the
    * account key.
    *
    * @param aWithUI a boolean for whether or not we should display authorization
    *                UI if we don't have a valid token anymore, or just fail out.
@@ -570,17 +570,17 @@ nsDropboxFileUploader.prototype = {
     let url = gServerUrl + kSharesPath + wwwFormUrlEncode(aFile.leafName);
     this.file = aFile;
     this.dropbox._connection.signAndSend(
       url, "", "POST", null,
       function(aResponseText, aRequest) {
         this.log.info("Getting share URL successful with response text: "
                       + aResponseText);
         let shareInfo = JSON.parse(aResponseText);
-        this.dropbox._urlsForFiles[this.file] = shareInfo.url;
+        this.dropbox._urlsForFiles[this.file.path] = shareInfo.url;
         aCallback(this.requestObserver, Cr.NS_OK);
       }.bind(this),
       function(aException, aResponseText, aRequest) {
         this.log.error("Getting share URL failed with response text: "
                        + aResponseText);
         aCallback(this.requestObserver, Cr.NS_ERROR_FAILURE);
       }.bind(this), this);
   },
--- a/mail/components/cloudfile/nsYouSendIt.js
+++ b/mail/components/cloudfile/nsYouSendIt.js
@@ -56,18 +56,18 @@ nsYouSendIt.prototype = {
   _request: null,
   _maxFileSize : -1,
   _fileSpaceUsed : -1,
   _availableStorage : -1,
   _lastErrorStatus : 0,
   _lastErrorText : "",
   _uploadingFile : null,
   _uploader : null,
-  _urlsForFiles : [],
-  _uploadInfo : [],
+  _urlsForFiles : {},
+  _uploadInfo : {},
   _uploads: [],
 
   /**
    * Used by our testing framework to override the URLs that this component
    * communicates to.
    */
   overrideUrls: function nsYouSendIt_overrideUrls(aNumUrls, aUrls) {
     gServerUrl = aUrls[0];
@@ -298,17 +298,17 @@ nsYouSendIt.prototype = {
   },
 
   /**
    * Returns the sharing URL for some uploaded file.
    *
    * @param aFile the nsILocalFile to get the URL for.
    */
   urlForFile: function nsYouSendIt_urlForFile(aFile) {
-    return this._urlsForFiles[aFile];
+    return this._urlsForFiles[aFile.path];
   },
 
   /**
    * Attempts to refresh cached profile information for the account associated
    * with this instance's account key.
    *
    * @param aWithUI a boolean for whether or not we should prompt the user for
    *                a password if we don't have a proper token.
@@ -876,17 +876,17 @@ nsYouSendItFileUploader.prototype = {
 
     req.onload = function() {
       // Response is the URL.
       let response = req.responseText;
       this.log.info("commit response = " + response);
       let uploadInfo = JSON.parse(response);
 
       if (uploadInfo.downloadUrl != null) {
-        this.youSendIt._urlsForFiles[this.file] = uploadInfo.downloadUrl;
+        this.youSendIt._urlsForFiles[this.file.path] = uploadInfo.downloadUrl;
         // Success!
         this.callback(this.requestObserver, Cr.NS_OK);
         return;
       }
       this.youSendIt._lastErrorText = uploadInfo.errorStatus.message;
       this.youSendIt._lastErrorStatus = uploadInfo.errorStatus.code;
       this.callback(this.requestObserver, Ci.nsIMsgCloudFileProvider.uploadErr);
     }.bind(this);