From 03bd19480ed80e5b78880f06d5cc316556af5a9a Mon Sep 17 00:00:00 2001 From: Intelli Date: Tue, 4 Jan 2022 17:55:52 -0700 Subject: [PATCH] Fixed SQLite purges not successfully completing on some systems --- src/main/java/net/coreprotect/command/PurgeCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coreprotect/command/PurgeCommand.java b/src/main/java/net/coreprotect/command/PurgeCommand.java index db37bd4..abe36cf 100755 --- a/src/main/java/net/coreprotect/command/PurgeCommand.java +++ b/src/main/java/net/coreprotect/command/PurgeCommand.java @@ -94,12 +94,14 @@ public class PurgeCommand extends Consumer { @Override public void run() { - try (Connection connection = Database.getConnection(false, 500)) { + try { long timestamp = (System.currentTimeMillis() / 1000L); long ptime = timestamp - seconds; long removed = 0; + Connection connection = null; for (int i = 0; i <= 5; i++) { + connection = Database.getConnection(false, 500); if (connection != null) { break; } @@ -342,6 +344,8 @@ public class PurgeCommand extends Consumer { } } + connection.close(); + if (abort) { if (!Config.getGlobal().MYSQL) { (new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp")).delete();