mirror of
https://github.com/filoghost/ChestCommands.git
synced 2024-11-23 10:35:16 +01:00
Change backups folder name and add "readme.txt"
This commit is contained in:
parent
e9f710a1d3
commit
6a00d49e06
@ -7,15 +7,19 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Backup {
|
public class Backup {
|
||||||
|
|
||||||
private final Path dataFolder;
|
private final Path dataFolder;
|
||||||
private final Path backupFolder;
|
private final Path backupFolder;
|
||||||
|
private final Path infoFile;
|
||||||
|
|
||||||
public Backup(Path dataFolder, String backupName) {
|
public Backup(Path dataFolder, String backupName) {
|
||||||
this.dataFolder = dataFolder;
|
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) {
|
public static Backup newTimestampedBackup(Path dataFolder) {
|
||||||
@ -31,6 +35,13 @@ public class Backup {
|
|||||||
if (!Files.isRegularFile(destination)) {
|
if (!Files.isRegularFile(destination)) {
|
||||||
Files.copy(fileToBackup, 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)."
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user