|
|
@@ -4,6 +4,7 @@ import cn.reghao.autodop.common.utils.data.db.CrudOps;
|
|
|
import cn.reghao.autodop.common.utils.data.db.PageList;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.LocalDir;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.orchestration.LocalDirRepository;
|
|
|
+import cn.reghao.autodop.dmaster.common.config.SysConfig;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
@@ -28,22 +29,13 @@ public class LocalDirCrudService implements CrudOps<LocalDir> {
|
|
|
@Override
|
|
|
public void addOrModify(LocalDir localDir) throws Exception {
|
|
|
// 检查并创建目录
|
|
|
- File localRepo = new File(localDir.getLocalRepo());
|
|
|
- if (!localRepo.exists() && !localRepo.mkdirs()) {
|
|
|
- throw new Exception(localDir.getLocalRepo() + "不存在且创建失败...");
|
|
|
- }
|
|
|
-
|
|
|
- File compileDir = new File(localDir.getCompileDir());
|
|
|
- if (!compileDir.exists() && !compileDir.mkdirs()) {
|
|
|
- throw new Exception(localDir.getCompileDir() + "不存在且创建失败...");
|
|
|
- }
|
|
|
-
|
|
|
- File packDir = new File(localDir.getPackDir());
|
|
|
- if (!packDir.exists() && !packDir.mkdirs()) {
|
|
|
- throw new Exception(localDir.getPackDir() + "不存在且创建失败...");
|
|
|
- }
|
|
|
+ checkOrMkdir(localDir.getLocalRepo());
|
|
|
+ checkOrMkdir(localDir.getCompileDir());
|
|
|
+ checkOrMkdir(localDir.getPackDir());
|
|
|
|
|
|
- LocalDir localDirEntity = localDirRepository.findByHostId(localDir.getHostId());
|
|
|
+ // 只做修改,不新增
|
|
|
+ String hostId = localDir.getHostId();
|
|
|
+ LocalDir localDirEntity = localDirRepository.findByHostId(hostId);
|
|
|
if (localDirEntity != null) {
|
|
|
localDir.setId(localDirEntity.getId());
|
|
|
localDir.setCreateTime(localDirEntity.getCreateTime());
|
|
|
@@ -51,6 +43,19 @@ public class LocalDirCrudService implements CrudOps<LocalDir> {
|
|
|
localDir.setIsDelete(localDirEntity.getIsDelete());
|
|
|
|
|
|
localDirRepository.save(localDir);
|
|
|
+
|
|
|
+ SysConfig.localRepo = localDir.getLocalRepo();
|
|
|
+ SysConfig.compileDir = localDir.getCompileDir();
|
|
|
+ SysConfig.packDir = localDir.getPackDir();
|
|
|
+ } else {
|
|
|
+ throw new Exception(hostId + " 不存在...");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkOrMkdir(String dirPath) throws Exception {
|
|
|
+ File dir = new File(dirPath);
|
|
|
+ if (!dir.exists() && !dir.mkdirs()) {
|
|
|
+ throw new Exception(dirPath + " 不存在且创建失败...");
|
|
|
}
|
|
|
}
|
|
|
|