Browse Source

优化

dev-lhz
chenzhihang 1 year ago
parent
commit
726039f246
3 changed files with 22 additions and 11 deletions
  1. +4
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  2. +9
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java
  3. +9
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java

+ 4
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java View File

@@ -384,8 +384,9 @@ public class NewDatasetServiceImpl implements NewDatasetService {

LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
dvcUtils.deleteDirectory(localPathlocal + "/" + ci4sUsername + "/datasets/" + repoId + "/" + repo);

String rootPath = localPathlocal + "/" + ci4sUsername + "/datasets/" + repoId + "/" + repo;
dvcUtils.deleteDirectory(rootPath);
FileUtil.renameFile(rootPath, rootPath + "_deleted");
}

@Override
@@ -394,6 +395,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
String rootPath = Paths.get(localPathlocal + "/" + relativePath).getParent().toString();
gitService.deleteBranch(token, owner, repo, version, rootPath);
dvcUtils.deleteDirectory(rootPath);
FileUtil.renameFile(rootPath, rootPath + "_deleted");
}

@Override


+ 9
- 9
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java View File

@@ -303,7 +303,7 @@ public class DVCUtils {
.call();
log.info("基于 master 的远程分支 " + branchName + " 创建成功。");
} catch (IOException | GitAPIException e) {
log.error("Exception occurred while creating local branch based on master",e);
log.error("Exception occurred while creating local branch based on master", e);
}
}

@@ -378,17 +378,17 @@ public class DVCUtils {
.call();

// 打印结果
pushResults.forEach(pr ->log.info(pr.getMessages()));
pushResults.forEach(pr -> log.info(pr.getMessages()));

log.info("分支 " + branchName + " 已成功推送到远程仓库。");
log.info("分支 " + branchName + " 已成功推送到远程仓库。");
}
}

/**
* 检查本地是否存在指定分支
*
* @param git Git 实例
* @param branchName 分支名称
* @param git Git 实例
* @param branchName 分支名称
* @return 如果本地存在该分支返回 true,否则返回 false
*/
private static boolean branchExistsLocally(Git git, String branchName) throws GitAPIException {
@@ -524,7 +524,7 @@ public class DVCUtils {



public void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
@@ -624,12 +624,12 @@ public class DVCUtils {
* @param branch 分支名称
* @return 包含文件路径、名称和大小的List<Map<String, Object>>
*/
public List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) {
public List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath, String username, String password) {
try {
//刷新
refreshRemoteBranches(localPath+"/" + repoFolder + "/"+ branch, username, password,branch);
refreshRemoteBranches(localPath + "/" + repoFolder + "/" + branch, username, password, branch);
// 读取data文件夹中的文件列表
String path = localPath + "/" + repoFolder + "/"+ branch + "/" + filePath;
String path = localPath + "/" + repoFolder + "/" + branch + "/" + filePath;

return FileUtil.getFiles(path);



+ 9
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/FileUtil.java View File

@@ -102,4 +102,13 @@ public class FileUtil {
return fileInfoList;
}

public static void renameFile(String oldPath ,String newPath){
File oldFolder = new File(oldPath);

// 新文件夹路径
File newFolder = new File(newPath);

// 重命名文件夹
boolean renamed = oldFolder.renameTo(newFolder);
}
}

Loading…
Cancel
Save