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,10 +71,12 @@ public class Config {
private void backupConfig(File currentConfigDir) throws IOException {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(RECORDING_DATE_FORMAT);
File src = currentConfigDir;
File target = new File(src.getParentFile(), src.getName() + "_backup_" + dateTimeFormatter.format(LocalDateTime.now()));
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);
deleteOldBackups(currentConfigDir);
if (src.exists()) {
File target = new File(src.getParentFile(), src.getName() + "_backup_" + dateTimeFormatter.format(LocalDateTime.now()));
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);
deleteOldBackups(currentConfigDir);
}
}
private void deleteOldBackups(File currentConfigDir) {