<commit_before>package monoxide.forgebackup.backup;

import java.io.File;
import java.util.List;

import monoxide.forgebackup.BackupLog;
import monoxide.forgebackup.compression.ICompressionHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.SaveHandler;

import com.google.common.collect.Lists;

public class BackupSettings {
	private final IBackupCleanup cleanup;
	private final String backupFolder;
	private final boolean backupWorld;
	private final boolean backupConfiguration;
	private final boolean backupMods;
	private final boolean backupServerConfiguration;
	private final String[] extraFiles;
	private final int[] disabledDimensions;
	private final int loggingLevel;
	private final MinecraftServer server;
	private final ICompressionHandler compression;

	public BackupSettings(
			MinecraftServer server, String backupFolder, int loggingLevel, IBackupCleanup cleanup,
			boolean backupWorld, boolean backupConfiguration, boolean backupMods, boolean backupServerConfiguration, String[] extraFiles,
			int[] disabledDimensions, ICompressionHandler compression
	) {
		this.server = server;
		this.backupFolder = backupFolder;
		this.loggingLevel = loggingLevel;
		this.cleanup = cleanup;
		this.backupWorld = backupWorld;
		this.backupConfiguration = backupConfiguration;
		this.backupMods = backupMods;
		this.backupServerConfiguration = backupServerConfiguration;
		this.extraFiles = extraFiles;
		this.disabledDimensions = disabledDimensions;
		this.compression = compression;
	}
	
	public IBackupCleanup getBackupCleanupHandler() {
		return cleanup;
	}
	
	public boolean willBackupWorld() {
		return backupWorld;
	}
	
	public boolean willBackupConfiguration() {
		return backupConfiguration;
	}
	
	public boolean willBackupMods() {
		return backupMods;
	}
	
	public boolean willBackupServerConfiguration() {
		return backupServerConfiguration;
	}
	
	public List<File> getExtraFilesToBackup(MinecraftServer server) {
		List<File> files = Lists.newArrayList();
		for (String file : extraFiles) {
			files.add(server.getFile(file));
		}
		return files;
	}
	
	public List<Integer> getDisabledDimensions() {
		List<Integer> dimensions = Lists.newArrayList();
		
		for (int d : disabledDimensions) {
			if (d == 0) {
				BackupLog.warning("Cannot disable overworld from backups.");
				continue;
			}
			dimensions.add(d);
		}
		
		return dimensions;
	}
	
	public int getLoggingLevel() {
		return loggingLevel;
	}
	
	public MinecraftServer getServer() {
		return server;
	}
	
	public ICompressionHandler getCompressionHandler() {
		return compression;
	}
	
	public File getBackupFolder() {
		File absoluteFile = server.getFile(backupFolder);
		File folder = absoluteFile.getAbsolutePath() == backupFolder ? absoluteFile : server.getFile(backupFolder);
		
		ISaveHandler saveHandler = server.worldServers[0].getSaveHandler();
		return new File(folder, saveHandler.getSaveDirectoryName());
	}
	
	public String getBackupFileName() {
		return getBackupCleanupHandler().getBackupFilename() + getCompressionHandler().getFileExtension();
	}

	public File getBackupFile() {
		return new File(getBackupFolder(), getBackupFileName());
	}

	public List<File> getFilesToBackup() {
		ISaveHandler saveHandler = server.worldServers[0].getSaveHandler();
		List<File> thingsToSave = Lists.newArrayList(getExtraFilesToBackup(server));
	
		if (willBackupWorld()) {
			if (saveHandler instanceof SaveHandler) {
				thingsToSave.add(((SaveHandler)saveHandler).getSaveDirectory());
			} else {
				thingsToSave.add(server.getFile(saveHandler.getSaveDirectoryName()));
			}
		}
		
		if (willBackupConfiguration()) {
			thingsToSave.add(server.getFile("config"));
		}
		
		if (willBackupMods()) {
			thingsToSave.add(server.getFile("mods"));
			thingsToSave.add(server.getFile("coremods"));
		}
		
		if (willBackupServerConfiguration()) {
			thingsToSave.add(server.getFile("banned-ips.txt"));
			thingsToSave.add(server.getFile("banned-players.txt"));
			thingsToSave.add(server.getFile("ops.txt"));
			thingsToSave.add(server.getFile("server.properties"));
			thingsToSave.add(server.getFile("white-list.txt"));
		}
		
		return thingsToSave;
	}
}
<commit_msg>Re-fix absolute paths for backup folders<commit_after>package monoxide.forgebackup.backup;

import java.io.File;
import java.util.List;

import monoxide.forgebackup.BackupLog;
import monoxide.forgebackup.compression.ICompressionHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.SaveHandler;

import com.google.common.collect.Lists;

public class BackupSettings {
	private final IBackupCleanup cleanup;
	private final String backupFolder;
	private final boolean backupWorld;
	private final boolean backupConfiguration;
	private final boolean backupMods;
	private final boolean backupServerConfiguration;
	private final String[] extraFiles;
	private final int[] disabledDimensions;
	private final int loggingLevel;
	private final MinecraftServer server;
	private final ICompressionHandler compression;

	public BackupSettings(
			MinecraftServer server, String backupFolder, int loggingLevel, IBackupCleanup cleanup,
			boolean backupWorld, boolean backupConfiguration, boolean backupMods, boolean backupServerConfiguration, String[] extraFiles,
			int[] disabledDimensions, ICompressionHandler compression
	) {
		this.server = server;
		this.backupFolder = backupFolder;
		this.loggingLevel = loggingLevel;
		this.cleanup = cleanup;
		this.backupWorld = backupWorld;
		this.backupConfiguration = backupConfiguration;
		this.backupMods = backupMods;
		this.backupServerConfiguration = backupServerConfiguration;
		this.extraFiles = extraFiles;
		this.disabledDimensions = disabledDimensions;
		this.compression = compression;
	}
	
	public IBackupCleanup getBackupCleanupHandler() {
		return cleanup;
	}
	
	public boolean willBackupWorld() {
		return backupWorld;
	}
	
	public boolean willBackupConfiguration() {
		return backupConfiguration;
	}
	
	public boolean willBackupMods() {
		return backupMods;
	}
	
	public boolean willBackupServerConfiguration() {
		return backupServerConfiguration;
	}
	
	public List<File> getExtraFilesToBackup(MinecraftServer server) {
		List<File> files = Lists.newArrayList();
		for (String file : extraFiles) {
			files.add(server.getFile(file));
		}
		return files;
	}
	
	public List<Integer> getDisabledDimensions() {
		List<Integer> dimensions = Lists.newArrayList();
		
		for (int d : disabledDimensions) {
			if (d == 0) {
				BackupLog.warning("Cannot disable overworld from backups.");
				continue;
			}
			dimensions.add(d);
		}
		
		return dimensions;
	}
	
	public int getLoggingLevel() {
		return loggingLevel;
	}
	
	public MinecraftServer getServer() {
		return server;
	}
	
	public ICompressionHandler getCompressionHandler() {
		return compression;
	}
	
	public File getBackupFolder() {
		File absoluteFile = server.getFile(backupFolder);
		File folder = absoluteFile.getAbsolutePath().equals(backupFolder) ? absoluteFile : server.getFile(backupFolder);
		
		ISaveHandler saveHandler = server.worldServers[0].getSaveHandler();
		return new File(folder, saveHandler.getSaveDirectoryName());
	}
	
	public String getBackupFileName() {
		return getBackupCleanupHandler().getBackupFilename() + getCompressionHandler().getFileExtension();
	}

	public File getBackupFile() {
		return new File(getBackupFolder(), getBackupFileName());
	}

	public List<File> getFilesToBackup() {
		ISaveHandler saveHandler = server.worldServers[0].getSaveHandler();
		List<File> thingsToSave = Lists.newArrayList(getExtraFilesToBackup(server));
	
		if (willBackupWorld()) {
			if (saveHandler instanceof SaveHandler) {
				thingsToSave.add(((SaveHandler)saveHandler).getSaveDirectory());
			} else {
				thingsToSave.add(server.getFile(saveHandler.getSaveDirectoryName()));
			}
		}
		
		if (willBackupConfiguration()) {
			thingsToSave.add(server.getFile("config"));
		}
		
		if (willBackupMods()) {
			thingsToSave.add(server.getFile("mods"));
			thingsToSave.add(server.getFile("coremods"));
		}
		
		if (willBackupServerConfiguration()) {
			thingsToSave.add(server.getFile("banned-ips.txt"));
			thingsToSave.add(server.getFile("banned-players.txt"));
			thingsToSave.add(server.getFile("ops.txt"));
			thingsToSave.add(server.getFile("server.properties"));
			thingsToSave.add(server.getFile("white-list.txt"));
		}
		
		return thingsToSave;
	}
}

{'fraction_non_alphanumeric': 0.1010600706713781, 'fraction_numerical': 0.0007067137809187279, 'mean_word_length': 5.336567164179105, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1686747', 'n_tokens_mistral': 2713, 'n_tokens_neox': 2447, 'n_words': 510}