backup wallets on shut down, skip when open on windows
This commit is contained in:
parent
4da41c5f18
commit
481b6c871a
@ -876,7 +876,19 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
public void saveWallet() {
|
public void saveWallet() {
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
if (wallet == null) throw new RuntimeException("Trade wallet is not open for trade " + getId());
|
if (wallet == null) throw new RuntimeException("Trade wallet is not open for trade " + getId());
|
||||||
xmrWalletService.saveWallet(wallet, !isArbitrator()); // skip backup if arbitrator
|
xmrWalletService.saveWallet(wallet);
|
||||||
|
maybeBackupWallet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void maybeBackupWallet() {
|
||||||
|
boolean createBackup = !isArbitrator() && !(Utilities.isWindows() && isWalletOpen()); // create backup unless arbitrator or windows and wallet is open (cannot copy file while open on windows)
|
||||||
|
if (createBackup) xmrWalletService.backupWallet(getWalletName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isWalletOpen() {
|
||||||
|
synchronized (walletLock) {
|
||||||
|
return wallet != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,7 +1325,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
// save wallet
|
// save wallet
|
||||||
if (wallet != null) {
|
if (wallet != null) {
|
||||||
try {
|
try {
|
||||||
xmrWalletService.saveWallet(wallet, false); // skip backup
|
xmrWalletService.saveWallet(wallet);
|
||||||
stopWallet();
|
stopWallet();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// warning will be logged for main wallet, so skip logging here
|
// warning will be logged for main wallet, so skip logging here
|
||||||
@ -1333,6 +1345,9 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
forceStopWallet();
|
forceStopWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// backup trade wallet if applicable
|
||||||
|
maybeBackupWallet();
|
||||||
|
|
||||||
// de-initialize
|
// de-initialize
|
||||||
if (idlePayoutSyncer != null) {
|
if (idlePayoutSyncer != null) {
|
||||||
xmrWalletService.removeWalletListener(idlePayoutSyncer);
|
xmrWalletService.removeWalletListener(idlePayoutSyncer);
|
||||||
|
@ -220,7 +220,7 @@ public class XmrWalletService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveMainWallet() {
|
public void saveMainWallet() {
|
||||||
saveMainWallet(true);
|
saveMainWallet(!(Utilities.isWindows() && wallet != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveMainWallet(boolean backup) {
|
public void saveMainWallet(boolean backup) {
|
||||||
@ -324,6 +324,10 @@ public class XmrWalletService {
|
|||||||
return syncWallet(wallet);
|
return syncWallet(wallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveWallet(MoneroWallet wallet) {
|
||||||
|
saveWallet(wallet, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void saveWallet(MoneroWallet wallet, boolean backup) {
|
public void saveWallet(MoneroWallet wallet, boolean backup) {
|
||||||
wallet.save();
|
wallet.save();
|
||||||
if (backup) backupWallet(wallet.getPath());
|
if (backup) backupWallet(wallet.getPath());
|
||||||
|
Loading…
Reference in New Issue
Block a user