From 0262356e2d0a79ac5459d8bf6cd4f553203ee2cb Mon Sep 17 00:00:00 2001 From: HopeLi <1278288511@qq.com> Date: Mon, 7 Jul 2025 16:10:24 +0800 Subject: [PATCH] =?UTF-8?q?0707=20ljc=20=20=20afl=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=93=8D=E4=BD=9C=E4=BB=A5=E5=8F=8A=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=93=8D=E4=BD=9C=E4=BB=A5=E5=8F=8A=E6=97=B6=E5=BA=8F?= =?UTF-8?q?=E8=A1=A8=E6=93=8D=E4=BD=9C=E7=AD=89=E6=8E=A5=E5=8F=A3=E5=BC=80?= =?UTF-8?q?=E5=8F=91=EF=BC=8C=E5=8C=85=E5=90=AB=E5=88=86=E7=89=87=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BB=A5=E5=8F=8A=E6=96=87=E4=BB=B6=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../casic/ci/process/util/SftpUploadUtil.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/module-ci-process-biz/src/main/java/cd/casic/ci/process/util/SftpUploadUtil.java b/modules/module-ci-process-biz/src/main/java/cd/casic/ci/process/util/SftpUploadUtil.java index f791762c..b43fdbb3 100644 --- a/modules/module-ci-process-biz/src/main/java/cd/casic/ci/process/util/SftpUploadUtil.java +++ b/modules/module-ci-process-biz/src/main/java/cd/casic/ci/process/util/SftpUploadUtil.java @@ -741,6 +741,11 @@ public class SftpUploadUtil { List copiedFiles = new ArrayList<>(); for (String sourceFilePath : sourceFilePaths) { + String chmodDir = sourceFilePath.substring(0, sourceFilePath.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); + // 获取源文件名 String sourceFileName = sourceFilePath.substring(sourceFilePath.lastIndexOf('/') + 1); @@ -865,6 +870,11 @@ public class SftpUploadUtil { channelSftp = (ChannelSftp) channel; + String chmodDir = remoteDir.substring(0, remoteDir.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); + // 切换到目标目录 channelSftp.cd(remoteDir); @@ -966,6 +976,11 @@ public class SftpUploadUtil { channelSftp = (ChannelSftp) channel; + String chmodDir = remoteDir.substring(0, remoteDir.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); + // 切换到目标目录 channelSftp.cd(remoteDir); @@ -1069,6 +1084,11 @@ public class SftpUploadUtil { session.connect(); System.out.println("SFTP Session 连接成功."); + String chmodDir = remoteDir.substring(0, remoteDir.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); + // 开始执行 find 命令 ChannelExec execChannel = (ChannelExec) session.openChannel("exec"); @@ -1196,6 +1216,11 @@ public class SftpUploadUtil { // 遍历远程文件路径并下载 for (String remoteFile : remoteFilePaths) { + String chmodDir = remoteFile.substring(0, remoteFile.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); + String fileName = new File(remoteFile).getName(); String localFilePath = localDir + fileName; @@ -1318,6 +1343,10 @@ public class SftpUploadUtil { System.out.println("SFTP Channel 打开成功."); channelSftp = (ChannelSftp) channel; + String chmodDir = remoteFilePath.substring(0, remoteFilePath.indexOf("default")); + log.info("分配权限路径,{}",chmodDir); + // 切换目录并列出内容用于调试 + sudoChmodORwx(session,chmodDir,password); String remoteDir = remoteFilePath.substring(0, remoteFilePath.lastIndexOf('/')); String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf('/') + 1);