Backup manager update : improved code handling file filtering + refactored PaperBackupManager + new Bungee backup manager

This commit is contained in:
2022-12-20 01:06:40 +01:00
parent 52467dc556
commit a7aa012fa4
10 changed files with 200 additions and 64 deletions

View File

@@ -59,7 +59,22 @@ public abstract class BackupProcess implements Comparable<BackupProcess>, Runnab
public abstract BiPredicate<File, String> getFilenameFilter();
public BiPredicate<File, String> getFilenameFilter() {
return (file, path) -> {
for (String exclude : ignoreList) {
if (exclude.startsWith("/")) { // relative to source of workdir
if (path.matches(exclude.substring(1)))
return false;
}
else {
String name = path.substring(path.lastIndexOf("/") + 1);
if (name.matches(exclude))
return false;
}
}
return true;
};
}
public abstract File getSourceDir();
@@ -98,6 +113,13 @@ public abstract class BackupProcess implements Comparable<BackupProcess>, Runnab
this.backupCleaner = backupCleaner;
}
public List<String> getIgnoreList() {
return ignoreList;
}
public void setIgnoreList(List<String> ignoreList) {
this.ignoreList = ignoreList;
}

View File

@@ -27,7 +27,7 @@ public class RotatedLogsBackupProcess extends BackupProcess {
@Override
public void run() {
// do not call super. We override the zip archive process, we just want to copy log files, here
// do not call super. We override the zip archive process, we just want to copy already-zipped log files.
if (inNewThread) {
new Thread(this::actuallyRun, "Backup Thread " + identifier).start();
}
@@ -40,6 +40,9 @@ public class RotatedLogsBackupProcess extends BackupProcess {
private void actuallyRun() {
if (!getSourceDir().isDirectory())
return;
Log.info("[Backup] Starting for " + ChatColor.GRAY + getDisplayName() + ChatColor.RESET + " ...");
try {