新增:算例目录创建的同时创建本地磁盘的算例目录
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sdm.common.utils;
|
||||
|
||||
import com.sdm.common.config.FlowableConfig;
|
||||
import com.sdm.common.entity.resp.data.LocalFileNodeVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -817,6 +818,33 @@ public class FilesUtil {
|
||||
return Pair.of(mainFileAbsolutePath, slaveFileList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态方法:创建 本地算例 目录
|
||||
* @param objectKey 目录名/子路径,调用者必须传递文件夹的路径
|
||||
* @return 成功返回完整路径字符串,失败返回 ""
|
||||
*/
|
||||
public static String createRunLocalDir(String objectKey) {
|
||||
// 入参非法直接返回空
|
||||
if (objectKey == null || objectKey.isBlank()) {
|
||||
log.warn("createRunLocalDir objectKey is blank");
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
// 拼接路径: /home/simulation + objectKey
|
||||
Path preDir = Paths.get(FlowableConfig.FLOWABLE_SIMULATION_BASEDIR).toAbsolutePath().normalize();
|
||||
Path targetDir = preDir.resolve(objectKey);
|
||||
// 关键:创建所有目录(已存在也不会报错)
|
||||
Files.createDirectories(targetDir);
|
||||
// 成功:返回完整路径
|
||||
return targetDir.toString();
|
||||
} catch (Exception e) {
|
||||
log.error("createRunLocalDir objectKey error:{} ",e.getMessage());
|
||||
// 权限不足、磁盘满、路径非法 → 都返回空
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归工具方法:遍历文件夹下所有层级的文件
|
||||
* @param dir 要遍历的目录
|
||||
|
||||
Reference in New Issue
Block a user