From c37423a737b87ff7b8cb36ac8faf9e9103fa4901 Mon Sep 17 00:00:00 2001 From: Jiri Peinlich Date: Mon, 26 May 2014 07:25:09 +0200 Subject: [PATCH] renaming to nonexisting file on Windows The method fails in case the file does not exists before renaming. canonical.delete() returns false in that case and the method throws an exception. --- core/src/main/java/com/google/bitcoin/core/Wallet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 41935cc3..0cba7518 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -328,7 +328,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha if (Utils.isWindows()) { // Work around an issue on Windows whereby you can't rename over existing files. File canonical = destFile.getCanonicalFile(); - if (!canonical.delete()) + if (canonical.exists() && !canonical.delete()) throw new IOException("Failed to delete canonical wallet file for replacement with autosave"); if (temp.renameTo(canonical)) return; // else fall through.