Create temporary file after halo is started

pull/565/head
johnniang 2020-02-05 18:08:29 +08:00
parent 08c579a095
commit e365537b70
2 changed files with 21 additions and 6 deletions

View File

@ -68,10 +68,4 @@ public class HaloProperties {
*/
private String cache = "memory";
public HaloProperties() throws IOException {
// Create work directory if not exist
Files.createDirectories(Paths.get(workDir));
Files.createDirectories(Paths.get(backupDir));
}
}

View File

@ -57,6 +57,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
public void onApplicationEvent(ApplicationStartedEvent event) {
this.migrate();
this.initThemes();
this.initDirectory();
this.printStartInfo();
}
@ -140,4 +141,24 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
return fileSystem;
}
private void initDirectory() {
Path workPath = Paths.get(haloProperties.getWorkDir());
Path backupPath = Paths.get(haloProperties.getBackupDir());
try {
if (Files.notExists(workPath)) {
Files.createDirectories(workPath);
log.info("Created work directory: [{}]", workPath);
}
if (Files.notExists(backupPath)) {
Files.createDirectories(backupPath);
log.info("Created backup directory: [{}]", backupPath);
}
} catch (IOException ie) {
throw new RuntimeException("Failed to initialize directories", ie);
}
}
}