Bug 1385402 - Cloud Storage API - Handle null while getting download folder r=gijs
MozReview-Commit-ID: C9HC4KSAuG4
--- 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;
},