electron-205: added logic to handle directory creation failure

This commit is contained in:
Vishwas Shashidhar
2017-11-16 09:10:35 +05:30
parent 69df38bf77
commit 27edab4da2

View File

@@ -244,9 +244,13 @@ function doCreateMainWindow(initialUrl, initialBounds) {
getConfigField('downloadsDirectory') getConfigField('downloadsDirectory')
.then((value) => { .then((value) => {
downloadsDirectory = value; downloadsDirectory = value;
// if the directory has been deleted, create it. // if the directory has been deleted, try creating it.
if (!fs.existsSync(downloadsDirectory)) { if (!fs.existsSync(downloadsDirectory)) {
fs.mkdirSync(downloadsDirectory); const directoryCreated = fs.mkdirSync(downloadsDirectory);
// If the directory creation failed, we use the default downloads directory
if (!directoryCreated) {
downloadsDirectory = null;
}
} }
}) })
.catch((error) => { .catch((error) => {