Only delete log files and nothing else
This commit is contained in:
parent
4a37ac3691
commit
59d45b6ede
@ -38,10 +38,21 @@ public class AutomaticLogDeleter extends JavaPlugin {
|
||||
//maximum file age allowed
|
||||
|
||||
long maxOldMillis = config.getLong("delete-logs-older-than-seconds") * 1000;
|
||||
String fileName;
|
||||
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
fileName = file.getName();
|
||||
|
||||
//if file is not a log file
|
||||
if (!fileName.endsWith(".log") && !fileName.endsWith(".log.gz")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//if file is older than configured time
|
||||
if ((System.currentTimeMillis() - file.lastModified()) > maxOldMillis) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file.delete()) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "[AutomaticLogDeleter] Failed to delete server log file! Are you sure the file permissions are correct?");
|
||||
@ -51,5 +62,4 @@ public class AutomaticLogDeleter extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user