ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42781] New: - optional task SCP (sftp=true) fails if remote dir does not exist or does contain "~"
Date Fri, 29 Jun 2007 16:24:28 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42781>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42781

           Summary: optional task SCP (sftp=true) fails if remote dir does
                    not exist or does contain "~"
           Product: Ant
           Version: 1.7.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: ErrorMessage, PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: ew@omikron.net


If task scp with sftp enabled is used, and the remote dir name contains "~"
(example: ~/), the task will fail with an "No such file" exception. I spent two
hours searching for the reason. The exception should be more meaningful.

Additionally the scp task will fail if the remote dir does not exist. The remote
dir should be created automatically if it does not exist.

Here is the patch for the changes I made on
org.apache.tools.ant.taskdefs.optional.ssh.ScpToMessageBySftp.java:

148a149
> 			// change dir on remote machine to the upload dir. create it if it does not
exist
149a151,158
> 		        try {
> 		            channel.stat(remotePath);
> 		        } catch (SftpException e) {
> 		            // dir does not exist.
> 		            if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
> 		                channel.mkdir(remotePath);
> 		            }
> 		        }
150a160,165
>             } catch (SftpException e) {
>             	throw new JSchException("failed changing remote dir to
'"+remotePath+"': "+e.toString());
>         	}
> 
>         	Directory current = null;
>         	try {
152c167
<                     Directory current = (Directory) i.next();
---
>                     current = (Directory) i.next();
156c171,175
<                 throw new JSchException(e.toString());
---
>             	if (current != null) {
>                 	throw new JSchException(e.toString()+" during sending
directory '"+current.getDirectory().getName()+"'");
>                 } else {
>                 	throw new JSchException(e.toString());
>                 }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message