1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-02 12:47:35 +02:00

Added data.save.hours setting to config. This allow control over how

long backups are retained.
This commit is contained in:
ElgarL
2011-10-16 08:58:45 +01:00
parent fff6601237
commit 2951cca559
6 changed files with 14 additions and 4 deletions

View File

@@ -47,4 +47,5 @@ v 1.4:
- Added a config setting - bukkit_perms_override: false - Added a config setting - bukkit_perms_override: false
Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager. Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
- Fixed reading world mirrors from the config. - Fixed reading world mirrors from the config.
- Simplified config.yml while retaining backwards compatibility. - Simplified config.yml while retaining backwards compatibility.
- Added data.save.hours setting to config. This allow control over how long backups are retained.

View File

@@ -11,6 +11,8 @@ settings:
save: save:
# How often GroupManager will save it's data back to groups and users.yml # How often GroupManager will save it's data back to groups and users.yml
minutes: 10 minutes: 10
# Number of hours to retain backups (plugins/GroupManager/backup)
hours: 24
logging: logging:
# level of detail GroupManager will use when logging. # level of detail GroupManager will use when logging.

View File

@@ -70,6 +70,10 @@ public class GMConfiguration {
public Integer getSaveInterval() { public Integer getSaveInterval() {
return GMconfig.getInt("settings.data.save.minutes", 10); return GMconfig.getInt("settings.data.save.minutes", 10);
} }
public Integer getBackupDuration() {
return GMconfig.getInt("settings.data.save.hours", 24);
}
public void adjustLoggerLevel() { public void adjustLoggerLevel() {

View File

@@ -163,6 +163,7 @@ public class GroupManager extends JavaPlugin {
int minutes = getGMConfig().getSaveInterval(); int minutes = getGMConfig().getSaveInterval();
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES); scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!"); GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
GroupManager.logger.info("Backups will be retained for " + getGMConfig().getBackupDuration() + " hours!");
} }
} }

View File

@@ -168,7 +168,7 @@ public class WorldsHolder {
if (alreadyDone.contains(w)) { if (alreadyDone.contains(w)) {
continue; continue;
} }
Tasks.removeOldFiles(plugin.getBackupFolder()); Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
if (w == null) { if (w == null) {
GroupManager.logger.severe("WHAT HAPPENED?"); GroupManager.logger.severe("WHAT HAPPENED?");
continue; continue;

View File

@@ -13,6 +13,8 @@ import java.io.OutputStream;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group; import org.anjocaido.groupmanager.data.Group;
/** /**
@@ -43,9 +45,9 @@ public abstract class Tasks {
copy(in, dst); copy(in, dst);
} }
public static void removeOldFiles(File folder) { public static void removeOldFiles(GroupManager gm, File folder) {
if (folder.isDirectory()) { if (folder.isDirectory()) {
long oldTime = System.currentTimeMillis() - 86400000L; long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000);
for (File olds : folder.listFiles()) { for (File olds : folder.listFiles()) {
if (olds.isFile()) { if (olds.isFile()) {
if (olds.lastModified() < oldTime) { if (olds.lastModified() < oldTime) {