Browse Source

Create remoteDir if needed, More meaningful error when exception occurs. PR 42781. Submitted by Eduard Wirch.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@677211 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
fd126ea830
4 changed files with 29 additions and 8 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +21
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java

+ 1
- 0
CONTRIBUTORS View File

@@ -74,6 +74,7 @@ Don Brown
Don Ferguson
Don Jeffery
Drew Sudell
Eduard Wirch
Edwin Woudt
Eli Tucker
Emmanuel Bourg


+ 3
- 0
WHATSNEW View File

@@ -104,6 +104,9 @@ Fixed bugs:
* XmlLogger could lose messages if <parallel> is used.
Bugzilla Report 25734.

* <scp> creates remoteToDir if it doesn't exist.
Bugzilla Report 42781

Other changes:
--------------



+ 4
- 0
contributors.xml View File

@@ -319,6 +319,10 @@
<first>Drew</first>
<last>Sudell</last>
</name>
<name>
<first>Eduard</first>
<last>Wirch</last>
</name>
<name>
<first>Edwin</first>
<last>Woudt</last>


+ 21
- 8
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java View File

@@ -153,24 +153,37 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
channel.connect();

try {
try {
channel.stat(remotePath);
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
// dir does not exist.
channel.mkdir(remotePath);
} else {
throw new JSchException("failed to access remote dir '"
+ remotePath + "'", e);
}
}
channel.cd(remotePath);
} catch (SftpException e) {
JSchException schException = new JSchException("Could not CD to '" + remotePath + "' - " + e.toString());
schException.initCause(e);
throw schException;
throw new JSchException("Could not CD to '" + remotePath
+ "' - " + e.toString(), e);
}
Directory current = null;
try {
for (Iterator i = directoryList.iterator(); i.hasNext();) {
Directory current = (Directory) i.next();
if(getVerbose()) {
current = (Directory) i.next();
if (getVerbose()) {
log("Sending directory " + current);
}
sendDirectory(channel, current);
}
} catch (SftpException e) {
JSchException schException = new JSchException(e.toString());
schException.initCause(e);
throw schException;
String msg = "Error sending directory";
if (current != null && current.getDirectory() != null) {
msg += " '" + current.getDirectory().getName() + "'";
}
throw new JSchException(msg, e);
}
} finally {
if (channel != null) {


Loading…
Cancel
Save