mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Throw when failed to back up wallet
Co-authored-by: Coolguy3289 <Coolguy3289@users.noreply.github.com>
This commit is contained in:
parent
54d31ef0cc
commit
de8169af32
2 changed files with 13 additions and 5 deletions
|
@ -21,8 +21,15 @@ module.exports = class DeleteAccount extends Command {
|
|||
header:
|
||||
`Are you sure you want to delete that account? *(${supportsCount.toLocaleString()} support[s])*`
|
||||
})) return;
|
||||
try {
|
||||
await Util.LBRY.deleteAccount(this.client, discordID, account.accountID);
|
||||
return message.channel.createMessage('Deleted account.');
|
||||
} catch (e) {
|
||||
return message.channel.createMessage(
|
||||
'Failed to delete the account. An error most likely occured while backing up the wallet.' +
|
||||
`\n\`\`\`\n${e.toString()}\`\`\``
|
||||
);
|
||||
}
|
||||
} else
|
||||
return message.channel.createMessage('That user does not have an account.');
|
||||
}
|
||||
|
|
|
@ -280,6 +280,7 @@ Util.LBRY = {
|
|||
} catch (err) {
|
||||
console.error('Error occurred while backing up wallet file!');
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Abandon supports
|
||||
|
@ -315,7 +316,7 @@ Util.LBRY = {
|
|||
return { count: supports.length };
|
||||
},
|
||||
backupWallet() {
|
||||
const wallet = fs.readFileSync(path.join(__dirname, config.walletPath));
|
||||
const wallet = fs.readFileSync(config.walletPath);
|
||||
const d = new Date();
|
||||
const date = [
|
||||
d.getUTCFullYear(),
|
||||
|
@ -329,7 +330,7 @@ Util.LBRY = {
|
|||
d.getUTCMilliseconds().toString()
|
||||
].join('-');
|
||||
const backupName = 'default_wallet.' + date + '_' + time + '.bak';
|
||||
const backupPath = path.join(__dirname, config.walletBackupFolder, backupName);
|
||||
const backupPath = path.join(config.walletBackupFolder, backupName);
|
||||
fs.writeFileSync(backupPath, wallet);
|
||||
console.log(`Backed up wallet file: ${backupPath}`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue