From 437a0b9a2bc4c71877533b6e7137a1e964cb1748 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 23 Oct 2008 01:38:54 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20delete=20lockfile=20on=20exit=20?= =?utf8?q?if=20file=20could=20not=20be=20locked.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/de/todesbaum/jsite/main/Configuration.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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() { -- 2.7.4