fix(settings): check for null pathToSave before to backup wallet

This commit is contained in:
George Lima 2019-01-13 00:06:05 -03:00
parent e966a80129
commit d5a658e4c6
1 changed files with 15 additions and 12 deletions

View File

@ -145,13 +145,19 @@ export class SettingsView extends PureComponent<Props, State> {
};
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`;
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 */
@ -162,9 +168,6 @@ export class SettingsView extends PureComponent<Props, State> {
);
}
electron.remote.dialog.showSaveDialog(
{ defaultPath: backupFileName },
async (pathToSave) => {
const [error] = await eres(
promisify(fs.copyFile)(walletDatPath, pathToSave),
);