fix: use deleteIfExists to work around potential race condition

This commit is contained in:
Johannes Frohnmeyer 2023-08-19 15:32:09 +02:00
parent a7a135c598
commit 8aa0555a2a
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}