forked from j62/ctbrec
1
0
Fork 0

Fix error in backupConfig, if config dir does not wxist yet

This commit is contained in:
0xb00bface 2022-11-12 21:09:33 +01:00
parent 97087c601a
commit 776cee271a
1 changed files with 6 additions and 4 deletions

View File

@ -71,11 +71,13 @@ public class Config {
private void backupConfig(File currentConfigDir) throws IOException { private void backupConfig(File currentConfigDir) throws IOException {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(RECORDING_DATE_FORMAT); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(RECORDING_DATE_FORMAT);
File src = currentConfigDir; File src = currentConfigDir;
if (src.exists()) {
File target = new File(src.getParentFile(), src.getName() + "_backup_" + dateTimeFormatter.format(LocalDateTime.now())); File target = new File(src.getParentFile(), src.getName() + "_backup_" + dateTimeFormatter.format(LocalDateTime.now()));
LOG.info("Creating a backup of the config in {}", target); LOG.info("Creating a backup of the config in {}", target);
FileUtils.copyDirectory(src, target, pathname -> !(pathname.toString().contains("minimal-browser") && pathname.toString().contains("Cache")), true); FileUtils.copyDirectory(src, target, pathname -> !(pathname.toString().contains("minimal-browser") && pathname.toString().contains("Cache")), true);
deleteOldBackups(currentConfigDir); deleteOldBackups(currentConfigDir);
} }
}
private void deleteOldBackups(File currentConfigDir) { private void deleteOldBackups(File currentConfigDir) {
File parent = currentConfigDir.getParentFile(); File parent = currentConfigDir.getParentFile();