From 955c2ba4d4f04cfbccb0714f6250776791e4d370 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 9 Jul 2014 00:50:50 +0200 Subject: [PATCH] fix windows file rename bug --- README.md | 1 + src/main/java/io/bitsquare/storage/Storage.java | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f996bfdea0..815612e083 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Then you can generate coins on demand with the Bitcoin qt client with that comma See: https://bitcoinj.github.io/testing You can change the network mode in the guice module: BitSquareModule.java +If you want to ### Resources: * Web: http://bitsquare.io diff --git a/src/main/java/io/bitsquare/storage/Storage.java b/src/main/java/io/bitsquare/storage/Storage.java index a5f5cf0065..13d37e106e 100644 --- a/src/main/java/io/bitsquare/storage/Storage.java +++ b/src/main/java/io/bitsquare/storage/Storage.java @@ -234,12 +234,15 @@ public class Storage if (Utils.isWindows()) { - // Work around an issue on Windows whereby you can't rename over existing files. final File canonical = storageFile.getCanonicalFile(); - if (canonical.exists() && !canonical.delete()) + if (!canonical.exists()) { - throw new IOException("Failed to delete canonical file for replacement with save"); + if (!canonical.createNewFile()) + { + throw new IOException("Failed to create new file " + canonical); + } } + if (!tempFile.renameTo(canonical)) { throw new IOException("Failed to rename " + tempFile + " to " + canonical);