diff --git a/common/src/main/java/haveno/common/file/FileUtil.java b/common/src/main/java/haveno/common/file/FileUtil.java index d0a4d6147b..f95a08cab3 100644 --- a/common/src/main/java/haveno/common/file/FileUtil.java +++ b/common/src/main/java/haveno/common/file/FileUtil.java @@ -39,6 +39,7 @@ import java.util.List; @Slf4j public class FileUtil { public static void rollingBackup(File dir, String fileName, int numMaxBackupFiles) { + if (numMaxBackupFiles <= 0) return; if (dir.exists()) { File backupDir = new File(Paths.get(dir.getAbsolutePath(), "backup").toString()); if (!backupDir.exists()) diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 991965edae..5fb822dee0 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -875,7 +875,7 @@ public abstract class Trade implements Tradable, Model { public void saveWallet() { synchronized (walletLock) { if (wallet == null) throw new RuntimeException("Trade wallet is not open for trade " + getId()); - xmrWalletService.saveWallet(wallet, true); + xmrWalletService.saveWallet(wallet, !isArbitrator()); // skip backup if arbitrator } } diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 46b8d37627..323e609af3 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -107,7 +107,7 @@ public class XmrWalletService { private static final String MONERO_WALLET_NAME = "haveno_XMR"; private static final String KEYS_FILE_POSTFIX = ".keys"; private static final String ADDRESS_FILE_POSTFIX = ".address.txt"; - private static final int NUM_MAX_BACKUP_WALLETS = 1; + private static final int NUM_MAX_WALLET_BACKUPS = 1; private static final int MONERO_LOG_LEVEL = 0; private static final int MAX_SYNC_ATTEMPTS = 3; private static final boolean PRINT_STACK_TRACE = false; @@ -361,9 +361,9 @@ public class XmrWalletService { } public void backupWallet(String walletName) { - FileUtil.rollingBackup(walletDir, walletName, NUM_MAX_BACKUP_WALLETS); - FileUtil.rollingBackup(walletDir, walletName + KEYS_FILE_POSTFIX, NUM_MAX_BACKUP_WALLETS); - FileUtil.rollingBackup(walletDir, walletName + ADDRESS_FILE_POSTFIX, NUM_MAX_BACKUP_WALLETS); + FileUtil.rollingBackup(walletDir, walletName, NUM_MAX_WALLET_BACKUPS); + FileUtil.rollingBackup(walletDir, walletName + KEYS_FILE_POSTFIX, NUM_MAX_WALLET_BACKUPS); + FileUtil.rollingBackup(walletDir, walletName + ADDRESS_FILE_POSTFIX, NUM_MAX_WALLET_BACKUPS); } public void deleteWalletBackups(String walletName) {