From 7a618c1463341adc6d4ad0b6aa4c589cc4c0004d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 10 Jan 2018 23:26:12 +0100 Subject: FileConfigStore: cleanup on rename problem Signed-off-by: Jason A. Donenfeld --- .../main/java/com/wireguard/android/configStore/FileConfigStore.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/src/main/java') 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 -- cgit v1.2.3