Browse Source

bz-64742 Fix SCP task (with sftp=true) to correctly parse the remote directory when fetching from root directory

master
Jaikiran Pai 4 years ago
parent
commit
a2b9f4c33e
2 changed files with 15 additions and 2 deletions
  1. +6
    -0
      WHATSNEW
  2. +9
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java

+ 6
- 0
WHATSNEW View File

@@ -1,5 +1,11 @@
Changes from Ant 1.10.9 TO Ant 1.10.10
======================================
Fixed bugs:
-----------

* SCP (with sftp=true) task would fail if fetching file located in root directory
Bugzilla Report 64742


Changes from Ant 1.10.8 TO Ant 1.10.9
=====================================


+ 9
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java View File

@@ -134,9 +134,16 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
final String remoteFile,
final File localFile) throws SftpException {
String pwd = remoteFile;
if (remoteFile.lastIndexOf('/') != -1) {
final int lastIndexOfFileSeparator = remoteFile.lastIndexOf('/');
if (lastIndexOfFileSeparator != -1) {
if (remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
if (lastIndexOfFileSeparator == 0) {
// the file path is of the form "/foo....." i.e. the file separator
// occurs at the start (and only there).
pwd = "/";
} else {
pwd = remoteFile.substring(0, lastIndexOfFileSeparator);
}
}
}
channel.cd(pwd);


Loading…
Cancel
Save