forked from LogBlock/LogBlock
Fixed drop old log method to clear -sign and -chest tables
This commit is contained in:
@ -308,16 +308,22 @@ public class LogBlock extends JavaPlugin
|
||||
}
|
||||
|
||||
private void dropOldLogs() {
|
||||
Connection conn = null;
|
||||
Connection conn = getConnection();
|
||||
if (conn == null)
|
||||
return;
|
||||
Statement state = null;
|
||||
try {
|
||||
conn = getConnection();
|
||||
if (conn == null)
|
||||
return;
|
||||
state = conn.createStatement();
|
||||
for (String table : Config.worldTables) {
|
||||
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) {
|
||||
log.log(Level.SEVERE, "[LogBlock] SQL exception", ex);
|
||||
|
Reference in New Issue
Block a user