fix(settings): check for null pathToSave before to backup wallet
This commit is contained in:
parent
e966a80129
commit
d5a658e4c6
|
@ -145,26 +145,29 @@ export class SettingsView extends PureComponent<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
backupWalletDat = async () => {
|
backupWalletDat = async () => {
|
||||||
const zcashDir = isDev ? `${HOME_DIR}/.zcash/testnet3` : HOME_DIR;
|
|
||||||
const walletDatPath = `${zcashDir}/wallet.dat`;
|
|
||||||
const backupFileName = `zcash-wallet-backup-${dateFns.format(
|
const backupFileName = `zcash-wallet-backup-${dateFns.format(
|
||||||
new Date(),
|
new Date(),
|
||||||
'YYYY-MM-DD-mm-ss',
|
'YYYY-MM-DD-mm-ss',
|
||||||
)}.dat`;
|
)}.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(
|
electron.remote.dialog.showSaveDialog(
|
||||||
{ defaultPath: backupFileName },
|
{ defaultPath: backupFileName },
|
||||||
async (pathToSave) => {
|
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(
|
const [error] = await eres(
|
||||||
promisify(fs.copyFile)(walletDatPath, pathToSave),
|
promisify(fs.copyFile)(walletDatPath, pathToSave),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue