3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

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.
This commit is contained in:
Jiri Peinlich 2014-05-26 07:25:09 +02:00 committed by Mike Hearn
parent 0442448621
commit c37423a737

View File

@ -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.