https://bz.apache.org/bugzilla/show_bug.cgi?id=66001
Bug ID: 66001 Summary: scp of directory from remote location fails if directory contains more than 10 files Product: Ant Version: 1.9.16 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: Optional Tasks Assignee: notifications@ant.apache.org Reporter: m.phill...@prosperodigital.com Target Milestone: --- Doing an scp of a directory recursively from a remote host and trying to preserve the modification date fails if more than 10 files are in the remote directory. My target that fails if remote dir contains more than 10 files <target name="scpGetRemoteDirToLocalDir"> <scp trust="true" recursive="true" preserveLastModified="true" password="${password}" file="${user}@${host}:${fullRemoteDir}" localTodir="${fullLocalDir}"></scp> </target> The problem is the channel.connect in setLastModified() is not followed by a channel.disconnect() The code in: fetchFile() { ... if (getPreserveLastModified()) { setLastModified(localFile); } } private void setLastModified(final File localFile) throws JSchException { SftpATTRS fileAttributes = null; final ChannelSftp channel = openSftpChannel(); # This connect does not have a disconnect(), so after 10 files my # transfer fails. channel.connect(); try { fileAttributes = channel.lstat(remoteDir(remoteFile) + localFile.getName()); } catch (final SftpException e) { throw new JSchException("failed to stat remote file", e); } FileUtils.getFileUtils().setFileLastModified(localFile, ((long) fileAttributes .getMTime()) * 1000); } # I modified the code to test: channel.connect(); String fileToStat = remoteDir(remoteFile) + localFile.getName(); try { fileAttributes = channel.lstat(fileToStat); } catch (final SftpException e) { throw new JSchException("failed to stat[" + fileToStat + "] remote file", e); } finally { channel.disconnect(); } This code is also broken in 1.10.12 -- You are receiving this mail because: You are the assignee for the bug.