diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java index bce3f78a9..96be3447f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java @@ -310,12 +310,16 @@ public class ScpFromMessage extends AbstractSshMessage { private void setLastModified(final File localFile) throws JSchException { SftpATTRS fileAttributes = null; final ChannelSftp channel = openSftpChannel(); - channel.connect(); try { - fileAttributes = channel.lstat(remoteDir(remoteFile) - + localFile.getName()); - } catch (final SftpException e) { - throw new JSchException("failed to stat remote file", e); + channel.connect(); + try { + fileAttributes = channel.lstat(remoteDir(remoteFile) + + localFile.getName()); + } catch (final SftpException e) { + throw new JSchException("failed to stat remote file", e); + } + } finally { + channel.disconnect(); } FileUtils.getFileUtils().setFileLastModified(localFile, ((long) fileAttributes |