summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-01-10 23:26:12 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-01-10 23:26:12 +0100
commit7a618c1463341adc6d4ad0b6aa4c589cc4c0004d (patch)
tree039ca27da5b0f97fe25371efa90ca607f0c7e083 /app/src/main/java/com
parentf8ee7dcce9748577aebef6677f9e6974c2dac03e (diff)
FileConfigStore: cleanup on rename problem
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index 4bc7a17e..f5cd01f0 100644
--- a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -76,8 +76,10 @@ public final class FileConfigStore implements ConfigStore {
final File replacementFile = fileFor(replacement);
if (!replacementFile.createNewFile())
throw new IOException("Configuration for " + replacement + " already exists");
- if (!file.renameTo(replacementFile))
+ if (!file.renameTo(replacementFile)) {
+ replacementFile.delete();
throw new IOException("Cannot rename configuration file " + file.getName());
+ }
}
@Override