diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index 07880e77..18f91f0f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -596,7 +596,7 @@ public class ModelsServiceImpl implements ModelsService { String rootPath = localPath + ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName; String modelPath = rootPath + "/model"; String metaPath = rootPath + "/metadata"; - String relatePath = ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName+ "/model"; + String relatePath = ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/model"; dvcUtils.gitClone(rootPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword); //干掉目标文件夹 @@ -675,6 +675,10 @@ public class ModelsServiceImpl implements ModelsService { String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); +// String ci4sUsername = "admin"; +// String gitLinkUsername = "fanshuai"; +// String gitLinkPassword = "h1n2x3j4y5@"; + Map userInfo = getUserInfo(ci4sUsername, gitLinkUsername, gitLinkPassword); String repositoryName = modelsVo.getIdentifier() == null ? ci4sUsername + "_model_" + DateUtils.dateTimeNow() : modelsVo.getIdentifier(); @@ -690,7 +694,6 @@ public class ModelsServiceImpl implements ModelsService { String owner = (String) userInfo.get("login"); String projectUrl = gitendpoint + "/" + owner + "/" + repositoryName + ".git"; - String sourcePath = modelsVo.getModelVersionVos().get(0).getUrl(); String rootPath = localPath + ci4sUsername + "/model/" + modelsVo.getId() + "/" + repositoryName; String modelPath = rootPath + "/model"; String metaPath = rootPath + "/metadata"; @@ -709,7 +712,15 @@ public class ModelsServiceImpl implements ModelsService { dvcUtils.dvcCheckout(rootPath); //干掉目标文件夹 dvcUtils.deleteDirectory(modelPath); - dvcUtils.moveFiles(sourcePath, modelPath); + if (modelsVo.getModelVersionVos().size() != 0) { + String sourcePath = modelsVo.getModelVersionVos().get(0).getUrl(); + dvcUtils.moveFiles(sourcePath, modelPath); + } + + if (modelsVo.getModelVersionVos().size() != 0) { + String sourcePath = modelsVo.getModelVersionVos().get(0).getUrl(); + dvcUtils.moveFiles(sourcePath, modelPath); + } //拼接生产的元数据后写入yaml文件 ModelMetaVo modelMetaVo = new ModelMetaVo(); @@ -779,7 +790,7 @@ public class ModelsServiceImpl implements ModelsService { // 构建objectName String username = SecurityUtils.getLoginUser().getUsername(); String fileName = file.getOriginalFilename(); - String path = localPath + "/temp/" + username + "/models/" + uuid; + String path = localPath + "temp/" + username + "/models/" + uuid; long sizeInBytes = file.getSize(); String formattedSize = FileUtil.formatFileSize(sizeInBytes); File targetFile = new File(path, file.getOriginalFilename()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java index edebbfad..20350123 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java @@ -635,6 +635,6 @@ public class DVCUtils { } catch (Exception e) { log.error("Error occurred while getting file details after git pull", e); } - return null; + return new ArrayList<>(); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java index f67cbf0d..12ff7de3 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java @@ -101,4 +101,5 @@ public class FileUtil { } return fileInfoList; } + }