Fixed drop old log method to clear -sign and -chest tables
This commit is contained in:
1 parent
31ebd41525
commit
0453371284
1 file changed
+11
-5
@@ -308,16 +308,22 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void dropOldLogs() {
|
private void dropOldLogs() {
|
||||||
Connection conn = null;
|
Connection conn = getConnection();
|
||||||
|
if (conn == null)
|
||||||
|
return;
|
||||||
Statement state = null;
|
Statement state = null;
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
|
||||||
if (conn == null)
|
|
||||||
return;
|
|
||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
for (String table : Config.worldTables) {
|
for (String table : Config.worldTables) {
|
||||||
int deleted = state.executeUpdate("DELETE FROM `" + table + "` WHERE date < date_sub(now(), INTERVAL " + Config.keepLogDays + " DAY)");
|
int deleted = state.executeUpdate("DELETE FROM `" + table + "` WHERE date < date_sub(now(), INTERVAL " + Config.keepLogDays + " DAY)");
|
||||||
log.info("[LogBlock] Cleared out table " + table + ". Deleted " + deleted + " entries.");
|
if (deleted > 0)
|
||||||
|
log.info("[LogBlock] Cleared out table " + table + ". Deleted " + deleted + " entries.");
|
||||||
|
deleted = state.executeUpdate("DELETE `" + table + "-sign` FROM `" + table + "-sign` LEFT JOIN `" + table + "` ON (`" + table + "-sign`.`id` = `" + table + "`.`id`) WHERE `" + table + "`.`id` IS NULL;");
|
||||||
|
if (deleted > 0)
|
||||||
|
log.info("[LogBlock] Cleared out table " + table + "-sign. Deleted " + deleted + " entries.");
|
||||||
|
deleted = state.executeUpdate("DELETE `" + table + "-chest` FROM `" + table + "-chest` LEFT JOIN `" + table + "` ON (`" + table + "-chest`.`id` = `" + table + "`.`id`) WHERE `" + table + "`.`id` IS NULL;");
|
||||||
|
if (deleted > 0)
|
||||||
|
log.info("[LogBlock] Cleared out table " + table + "-chest. Deleted " + deleted + " entries.");
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.log(Level.SEVERE, "[LogBlock] SQL exception", ex);
|
log.log(Level.SEVERE, "[LogBlock] SQL exception", ex);
|
||||||
|
|||||||
Reference in new issue
Block a user