FileConfigStore: cleanup on rename problem
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
f8ee7dcce9
commit
7a618c1463
@ -76,9 +76,11 @@ public final class FileConfigStore implements ConfigStore {
|
|||||||
final File replacementFile = fileFor(replacement);
|
final File replacementFile = fileFor(replacement);
|
||||||
if (!replacementFile.createNewFile())
|
if (!replacementFile.createNewFile())
|
||||||
throw new IOException("Configuration for " + replacement + " already exists");
|
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());
|
throw new IOException("Cannot rename configuration file " + file.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Config save(final String name, final Config config) throws IOException {
|
public Config save(final String name, final Config config) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user