mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 04:35:14 +08:00
修正SshjSftp
在SftpSubsystem服务时报错问题(pr#1338@Gitee)
This commit is contained in:
parent
25327585b1
commit
fc4a71200a
@ -19,6 +19,7 @@
|
||||
### 🐞Bug修复
|
||||
* 【setting】 修复`Setting`autoLoad可能的加载为空的问题(issue#3919@Github)
|
||||
* 【db 】 修复某些数据库的getParameterMetaData会返回NULL,导致空指针的问题。(pr#3936@Github)
|
||||
* 【extra 】 修正`SshjSftp`在SftpSubsystem服务时报错问题(pr#1338@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.37(2025-03-31)
|
||||
|
@ -128,28 +128,6 @@ public class SshjSftp extends AbstractFtp {
|
||||
return this;
|
||||
}
|
||||
|
||||
private String getPath(String path) {
|
||||
if (StrUtil.isBlank(this.workingDir)) {
|
||||
try {
|
||||
this.workingDir = sftp.canonicalize("");
|
||||
} catch (IOException e) {
|
||||
throw new FtpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(path)) {
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
// 如果是绝对路径,则返回
|
||||
if (StrUtil.startWith(path, StrUtil.SLASH)) {
|
||||
return path;
|
||||
} else {
|
||||
String tmp = StrUtil.removeSuffix(this.workingDir, StrUtil.SLASH);
|
||||
return StrUtil.format("{}/{}", tmp, path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变目录,注意目前不支持..
|
||||
* @param directory directory
|
||||
@ -327,4 +305,26 @@ public class SshjSftp extends AbstractFtp {
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
private String getPath(String path) {
|
||||
if (StrUtil.isBlank(this.workingDir)) {
|
||||
try {
|
||||
this.workingDir = sftp.canonicalize("");
|
||||
} catch (IOException e) {
|
||||
throw new FtpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(path)) {
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
// 如果是绝对路径,则返回
|
||||
if (StrUtil.startWith(path, StrUtil.SLASH)) {
|
||||
return path;
|
||||
} else {
|
||||
String tmp = StrUtil.removeSuffix(this.workingDir, StrUtil.SLASH);
|
||||
return StrUtil.format("{}/{}", tmp, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void renameTest() {
|
||||
final Ftp ftp = new Ftp("localhost", 21, "test", "test");
|
||||
|
||||
|
@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
* @author youyongkun
|
||||
* @since 5.7.18
|
||||
*/
|
||||
@Disabled
|
||||
class SshjSftpTest {
|
||||
|
||||
private static SshjSftp sshjSftp;
|
||||
@ -68,6 +69,7 @@ class SshjSftpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void pwdTest() {
|
||||
// mkDirsTest();
|
||||
sshjSftp.cd("/ftp");
|
||||
@ -77,6 +79,7 @@ class SshjSftpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void renameTest() {
|
||||
// sshjSftp.mkdir("/ftp-1");
|
||||
assertTrue(sshjSftp.exist("/ftp-1"));
|
||||
|
Loading…
Reference in New Issue
Block a user