Bug 1385402 - Cloud Storage API - Handle null while getting download folder r=gijs draft
authorPunam <pdahiya@mozilla.com>
Sun, 30 Jul 2017 14:52:26 -0700
changeset 618234 af5e96e9731ae38eb4de79a260fe9bad53d76f0f
parent 618230 6025b5b43ec638821540a4199be4c10e2160f6e3
child 639999 09599701aa863f592827e0c6aec214084f49a52b
push id71256
push userbmo:pdahiya@mozilla.com
push dateSun, 30 Jul 2017 22:02:12 +0000
reviewersgijs
bugs1385402
milestone56.0a1
Bug 1385402 - Cloud Storage API - Handle null while getting download folder r=gijs MozReview-Commit-ID: C9HC4KSAuG4
toolkit/components/cloudstorage/CloudStorage.jsm
toolkit/components/jsdownloads/src/DownloadIntegration.jsm
--- a/toolkit/components/cloudstorage/CloudStorage.jsm
+++ b/toolkit/components/cloudstorage/CloudStorage.jsm
@@ -393,16 +393,17 @@ var CloudStorageInternal = {
 
   /**
    * Retrieve download folder of preferred provider by type specific data
    *
    * @param dataType
    *        type of data downloaded, options are 'default', 'screenshot'
    *        default value is 'default'
    * @return {Promise} which resolves to full path to download folder
+   * Resolves null if a valid download folder is not found.
    */
   async getDownloadFolder(dataType = "default") {
     // Wait for cloudstorage to initialize if providers metadata is not available
     if (!this.providersMetaData) {
       let isInitialized = await this.promiseInit;
       if (!isInitialized && !this.providersMetaData) {
         Cu.reportError("CloudStorage: Failed to initialize and retrieve download folder ");
         return null;
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -311,18 +311,18 @@ this.DownloadIntegration = {
         } catch(ex) {
           // Either the preference isn't set or the directory cannot be created.
           directoryPath = await this.getSystemDownloadsDirectory();
         }
         break;
       case 3: // Cloud Storage
         try {
           directoryPath = await CloudStorage.getDownloadFolder();
-        } catch(ex) {
-          // Either the preference isn't set or the directory cannot be created.
+        } catch(ex) {}
+        if (!directoryPath) {
           directoryPath = await this.getSystemDownloadsDirectory();
         }
         break;
       default:
         directoryPath = await this.getSystemDownloadsDirectory();
     }
     return directoryPath;
   },