Change backups folder name and add "readme.txt"

This commit is contained in:
filoghost 2020-07-24 18:06:09 +02:00
parent e9f710a1d3
commit 6a00d49e06

View File

@ -7,15 +7,19 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
public class Backup {
private final Path dataFolder;
private final Path backupFolder;
private final Path infoFile;
public Backup(Path dataFolder, String backupName) {
this.dataFolder = dataFolder;
this.backupFolder = dataFolder.resolve("backups").resolve(backupName);
Path backupsFolder = dataFolder.resolve("old_files");
this.backupFolder = backupsFolder.resolve(backupName);
this.infoFile = backupsFolder.resolve("readme.txt");
}
public static Backup newTimestampedBackup(Path dataFolder) {
@ -31,6 +35,13 @@ public class Backup {
if (!Files.isRegularFile(destination)) {
Files.copy(fileToBackup, destination);
}
if (!Files.isRegularFile(infoFile)) {
Files.write(infoFile, Arrays.asList(
"Files in this folders are copies of original configuration files that have been automatically upgraded.",
"",
"Note: some configuration upgrades remove comments and other formatting (such as empty lines)."
));
}
}
}