From: David ‘Bombe’ Roden Date: Wed, 22 Oct 2008 23:38:54 +0000 (+0200) Subject: Don’t delete lockfile on exit if file could not be locked. X-Git-Tag: 0.7~42 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=437a0b9a2bc4c71877533b6e7137a1e964cb1748;p=jSite.git Don’t delete lockfile on exit if file could not be locked. --- diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 3322c03..b38e986 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -113,9 +113,12 @@ public class Configuration { return false; } File lockFile = new File(lockFilename); - lockFile.deleteOnExit(); try { - return lockFile.createNewFile(); + boolean fileLocked = lockFile.createNewFile(); + if (fileLocked) { + lockFile.deleteOnExit(); + } + return fileLocked; } catch (IOException e) { /* ignore. */ } @@ -123,6 +126,13 @@ public class Configuration { } /** + * Tells the VM to remove the lock file on program exit. + */ + public void removeLockfileOnExit() { + new File(lockFilename).deleteOnExit(); + } + + /** * Reads the configuration from the file. */ private void readConfiguration() {