You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2022/04/08 17:05:20 UTC

[Bug 66001] New: scp of directory from remote location fails if directory contains more than 10 files

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.phillips@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.

[Bug 66001] scp of directory from remote location fails if directory contains more than 10 files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66001

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |1.9.17
         Resolution|---                         |FIXED

--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
Thanks, Mike, will be fixed in 1.9.17 and 1.10.13

-- 
You are receiving this mail because:
You are the assignee for the bug.