mirror of https://github.com/halo-dev/halo
Create temporary file after halo is started
parent
08c579a095
commit
e365537b70
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue