diff options
author | ElgarL <ElgarL@palmergames.com> | 2011-10-16 08:58:45 +0100 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2011-10-16 08:58:45 +0100 |
commit | 569af0bcf02a057f076aaea168109eb1a7b3faec (patch) | |
tree | bb3de79e85f703d61d8f8e590123d2e0963699ba | |
parent | e04936455780f0649d4ae7975aeadd061fad1d29 (diff) | |
download | Essentials-569af0bcf02a057f076aaea168109eb1a7b3faec.tar Essentials-569af0bcf02a057f076aaea168109eb1a7b3faec.tar.gz Essentials-569af0bcf02a057f076aaea168109eb1a7b3faec.tar.lz Essentials-569af0bcf02a057f076aaea168109eb1a7b3faec.tar.xz Essentials-569af0bcf02a057f076aaea168109eb1a7b3faec.zip |
Added data.save.hours setting to config. This allow control over how
long backups are retained.
6 files changed, 14 insertions, 4 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 4f4851f0a..6729907b5 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -47,4 +47,5 @@ v 1.4: - Added a config setting - bukkit_perms_override: false
Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
- Fixed reading world mirrors from the config.
- - Simplified config.yml while retaining backwards compatibility.
\ No newline at end of file + - Simplified config.yml while retaining backwards compatibility.
+ - Added data.save.hours setting to config. This allow control over how long backups are retained.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml index caa675527..25fb5dcd0 100644 --- a/EssentialsGroupManager/src/config.yml +++ b/EssentialsGroupManager/src/config.yml @@ -11,6 +11,8 @@ settings: save: # How often GroupManager will save it's data back to groups and users.yml minutes: 10 + # Number of hours to retain backups (plugins/GroupManager/backup) + hours: 24 logging: # level of detail GroupManager will use when logging. diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java index 302f12b67..ad2945076 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java @@ -70,6 +70,10 @@ public class GMConfiguration { public Integer getSaveInterval() { return GMconfig.getInt("settings.data.save.minutes", 10); } + + public Integer getBackupDuration() { + return GMconfig.getInt("settings.data.save.hours", 24); + } public void adjustLoggerLevel() { diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 1f55f73ad..5ef4fc537 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -163,6 +163,7 @@ public class GroupManager extends JavaPlugin { int minutes = getGMConfig().getSaveInterval(); scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES); GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!"); + GroupManager.logger.info("Backups will be retained for " + getGMConfig().getBackupDuration() + " hours!"); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java index 573fcebc3..7cbe4f65c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -168,7 +168,7 @@ public class WorldsHolder { if (alreadyDone.contains(w)) { continue; } - Tasks.removeOldFiles(plugin.getBackupFolder()); + Tasks.removeOldFiles(plugin, plugin.getBackupFolder()); if (w == null) { GroupManager.logger.severe("WHAT HAPPENED?"); continue; diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java index 8e4d58dde..f3defd94a 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java @@ -13,6 +13,8 @@ import java.io.OutputStream; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; + +import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.data.Group; /** @@ -43,9 +45,9 @@ public abstract class Tasks { copy(in, dst); } - public static void removeOldFiles(File folder) { + public static void removeOldFiles(GroupManager gm, File folder) { if (folder.isDirectory()) { - long oldTime = System.currentTimeMillis() - 86400000L; + long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000); for (File olds : folder.listFiles()) { if (olds.isFile()) { if (olds.lastModified() < oldTime) { |