forked from j62/ctbrec
Fix error in backupConfig, if config dir does not wxist yet
This commit is contained in:
parent
97087c601a
commit
776cee271a
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue