From 8aa0555a2aa493a6ac4f692c3943f817b7a7a164 Mon Sep 17 00:00:00 2001 From: JFronny Date: Sat, 19 Aug 2023 15:32:09 +0200 Subject: [PATCH] fix: use deleteIfExists to work around potential race condition --- .../jfronny/inceptum/launcher/system/instance/Instance.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java index 9c138c0..bbf00a2 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java @@ -116,7 +116,7 @@ public record Instance(String id, Path path, InstanceMeta meta, ModsDirScanner m try { if (ProcessUtils.isProcessAlive(Files.readString(path.resolve(LOCK_NAME)))) return true; - Files.delete(path.resolve(LOCK_NAME)); + Files.deleteIfExists(path.resolve(LOCK_NAME)); } catch (IOException e) { Utils.LOGGER.error("Could not read running lock of " + getName(), e); }