mirror of https://github.com/halo-dev/halo
fix: 网站备份时,上级目录不存在的问题 (#1056)
* 增加网站备份,临时文件不存在时创建 * 增加数据导出,临时文件不存在时创建 * 修改整站备份,数据导出,临时文件不存在时创建pull/1066/head
parent
dd4c602526
commit
236b3c418f
|
@ -177,7 +177,11 @@ public class BackupServiceImpl implements BackupService {
|
|||
DateTimeUtils.format(LocalDateTime.now(), DateTimeUtils.HORIZONTAL_LINE_DATETIME_FORMATTER) +
|
||||
IdUtil.simpleUUID().hashCode() + ".zip";
|
||||
// Create halo zip file
|
||||
Path haloZipPath = Files.createFile(Paths.get(haloProperties.getBackupDir(), haloZipFileName));
|
||||
Path haloZipFilePath = Paths.get(haloProperties.getBackupDir(), haloZipFileName);
|
||||
if (!Files.exists(haloZipFilePath.getParent())) {
|
||||
Files.createDirectories(haloZipFilePath.getParent());
|
||||
}
|
||||
Path haloZipPath = Files.createFile(haloZipFilePath);
|
||||
|
||||
// Zip halo
|
||||
run.halo.app.utils.FileUtils.zip(Paths.get(this.haloProperties.getWorkDir()), haloZipPath);
|
||||
|
@ -297,7 +301,11 @@ public class BackupServiceImpl implements BackupService {
|
|||
DateTimeUtils.format(LocalDateTime.now(), DateTimeUtils.HORIZONTAL_LINE_DATETIME_FORMATTER) +
|
||||
IdUtil.simpleUUID().hashCode() + ".json";
|
||||
|
||||
Path haloDataPath = Files.createFile(Paths.get(haloProperties.getDataExportDir(), haloDataFileName));
|
||||
Path haloDataFilePath = Paths.get(haloProperties.getDataExportDir(), haloDataFileName);
|
||||
if (!Files.exists(haloDataFilePath.getParent())) {
|
||||
Files.createDirectories(haloDataFilePath.getParent());
|
||||
}
|
||||
Path haloDataPath = Files.createFile(haloDataFilePath);
|
||||
|
||||
FileWriter fileWriter = new FileWriter(haloDataPath.toFile(), CharsetUtil.UTF_8);
|
||||
fileWriter.write(JsonUtils.objectToJson(data));
|
||||
|
|
Loading…
Reference in New Issue