diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index 2de64bbe..7b07fd9e 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -312,7 +312,8 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi if (Utils.isWindows()) { // Work around an issue on Windows whereby you can't rename over existing files. File canonical = destFile.getCanonicalFile(); - canonical.delete(); + if (!canonical.delete()) + throw new IOException("Failed to delete canonical wallet file for replacement with autosave"); if (temp.renameTo(canonical)) return; // else fall through. throw new IOException("Failed to rename " + temp + " to " + canonical); @@ -327,8 +328,8 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi if (stream != null) { stream.close(); } - if (temp.delete()) { - log.warn("Deleted temp file after failed save."); + if (temp.exists()) { + log.warn("Temp file still exists after failed save."); } } }