From d5a658e4c62082f1c48dba6842bfaf059ff87a79 Mon Sep 17 00:00:00 2001 From: George Lima Date: Sun, 13 Jan 2019 00:06:05 -0300 Subject: [PATCH] fix(settings): check for null pathToSave before to backup wallet --- app/views/settings.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/views/settings.js b/app/views/settings.js index 0e8a2ff..8002668 100644 --- a/app/views/settings.js +++ b/app/views/settings.js @@ -145,26 +145,29 @@ export class SettingsView extends PureComponent { }; backupWalletDat = async () => { - const zcashDir = isDev ? `${HOME_DIR}/.zcash/testnet3` : HOME_DIR; - const walletDatPath = `${zcashDir}/wallet.dat`; const backupFileName = `zcash-wallet-backup-${dateFns.format( new Date(), 'YYYY-MM-DD-mm-ss', )}.dat`; - const [cannotAccess] = await eres(promisify(fs.access)(walletDatPath)); - - /* eslint-disable no-alert */ - - if (cannotAccess) { - alert( - "Couldn't backup the wallet.dat file. You need to back it up manually.", - ); - } - electron.remote.dialog.showSaveDialog( { defaultPath: backupFileName }, async (pathToSave) => { + if (!pathToSave) return; + + const zcashDir = isDev ? `${HOME_DIR}/.zcash/testnet3` : HOME_DIR; + const walletDatPath = `${zcashDir}/wallet.dat`; + + const [cannotAccess] = await eres(promisify(fs.access)(walletDatPath)); + + /* eslint-disable no-alert */ + + if (cannotAccess) { + alert( + "Couldn't backup the wallet.dat file. You need to back it up manually.", + ); + } + const [error] = await eres( promisify(fs.copyFile)(walletDatPath, pathToSave), );