mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Actually keep all weeks, not just from the past year
Week numbers are obviously the same every year, we need to check the year as well as the week number to determine if we should keep the backup file or not.
This commit is contained in:
parent
3b1bb3e08a
commit
7a08343304
@ -23,6 +23,7 @@ Version 1.4.08-dev
|
|||||||
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
|
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
|
||||||
= Fixed bug where cooldown donor perks were reducing more than expected
|
= Fixed bug where cooldown donor perks were reducing more than expected
|
||||||
= Fixed bug where disabling hardcore mode for specific skills didn't work
|
= Fixed bug where disabling hardcore mode for specific skills didn't work
|
||||||
|
= Fixed bug which caused the backup cleanup to delete old backups while it should've kept those
|
||||||
! Updated localization files
|
! Updated localization files
|
||||||
! Changed AxesCritical to CriticalHit in config file
|
! Changed AxesCritical to CriticalHit in config file
|
||||||
! Changed several secondary ability permissions(deprecated versions still exist)
|
! Changed several secondary ability permissions(deprecated versions still exist)
|
||||||
|
@ -6,13 +6,14 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
|
||||||
public class CleanBackupsTask extends BukkitRunnable {
|
public class CleanBackupsTask extends BukkitRunnable {
|
||||||
private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator;
|
private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator;
|
||||||
@ -21,7 +22,7 @@ public class CleanBackupsTask extends BukkitRunnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<Integer> savedDays = new ArrayList<Integer>();
|
List<Integer> savedDays = new ArrayList<Integer>();
|
||||||
List<Integer> savedWeeks = new ArrayList<Integer>();
|
HashMap<Integer, List<Integer>> savedYearsWeeks = new HashMap<Integer, List<Integer>>();
|
||||||
List<File> toDelete = new ArrayList<File>();
|
List<File> toDelete = new ArrayList<File>();
|
||||||
int amountTotal = 0;
|
int amountTotal = 0;
|
||||||
int amountDeleted = 0;
|
int amountDeleted = 0;
|
||||||
@ -51,6 +52,7 @@ public class CleanBackupsTask extends BukkitRunnable {
|
|||||||
cal.setTime(date);
|
cal.setTime(date);
|
||||||
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
||||||
int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
|
int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
|
||||||
|
int year = cal.get(Calendar.YEAR);
|
||||||
|
|
||||||
if (isPast24Hours(date) && Config.getInstance().getKeepLast24Hours()) {
|
if (isPast24Hours(date) && Config.getInstance().getKeepLast24Hours()) {
|
||||||
// Keep all files from the last 24 hours
|
// Keep all files from the last 24 hours
|
||||||
@ -61,11 +63,19 @@ public class CleanBackupsTask extends BukkitRunnable {
|
|||||||
savedDays.add(dayOfWeek);
|
savedDays.add(dayOfWeek);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) {
|
else {
|
||||||
|
List<Integer> savedWeeks = savedYearsWeeks.get(year);
|
||||||
|
if (savedWeeks == null) {
|
||||||
|
savedWeeks = new ArrayList<Integer>();
|
||||||
|
savedYearsWeeks.put(year, savedWeeks);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) {
|
||||||
// Keep one backup of each week
|
// Keep one backup of each week
|
||||||
savedWeeks.add(weekOfYear);
|
savedWeeks.add(weekOfYear);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
amountDeleted++;
|
amountDeleted++;
|
||||||
toDelete.add(file);
|
toDelete.add(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user