mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修正SshjSftp
在SftpSubsystem服务时报错问题(pr#1338@Gitee)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user