|
@@ -39,6 +39,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { |
|
|
private File localFile; |
|
|
private File localFile; |
|
|
private final String remotePath; |
|
|
private final String remotePath; |
|
|
private List directoryList; |
|
|
private List directoryList; |
|
|
|
|
|
private final boolean preserveLastModified; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor for a local file to remote. |
|
|
* Constructor for a local file to remote. |
|
@@ -52,11 +53,31 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { |
|
|
final Session session, |
|
|
final Session session, |
|
|
final File aLocalFile, |
|
|
final File aLocalFile, |
|
|
final String aRemotePath) { |
|
|
final String aRemotePath) { |
|
|
this(verbose, session, aRemotePath); |
|
|
|
|
|
|
|
|
this(verbose, session, aLocalFile, aRemotePath, false); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Constructor for a local file to remote. |
|
|
|
|
|
* @param verbose if true do verbose logging |
|
|
|
|
|
* @param session the scp session to use |
|
|
|
|
|
* @param aLocalFile the local file |
|
|
|
|
|
* @param aRemotePath the remote path |
|
|
|
|
|
* @param preserveLastModified True if the last modified time needs to be preserved |
|
|
|
|
|
* on the transferred files. False otherwise. |
|
|
|
|
|
* @since Ant 1.9.10 |
|
|
|
|
|
*/ |
|
|
|
|
|
public ScpToMessageBySftp(final boolean verbose, |
|
|
|
|
|
final Session session, |
|
|
|
|
|
final File aLocalFile, |
|
|
|
|
|
final String aRemotePath, |
|
|
|
|
|
final boolean preserveLastModified) { |
|
|
|
|
|
this(verbose, session, aRemotePath, preserveLastModified); |
|
|
|
|
|
|
|
|
this.localFile = aLocalFile; |
|
|
this.localFile = aLocalFile; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor for a local directories to remote. |
|
|
* Constructor for a local directories to remote. |
|
|
* @param verbose if true do verbose logging |
|
|
* @param verbose if true do verbose logging |
|
@@ -69,23 +90,45 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { |
|
|
final Session session, |
|
|
final Session session, |
|
|
final List aDirectoryList, |
|
|
final List aDirectoryList, |
|
|
final String aRemotePath) { |
|
|
final String aRemotePath) { |
|
|
this(verbose, session, aRemotePath); |
|
|
|
|
|
|
|
|
this(verbose, session, aDirectoryList, aRemotePath, false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Constructor for a local directories to remote. |
|
|
|
|
|
* @param verbose if true do verbose logging |
|
|
|
|
|
* @param session the scp session to use |
|
|
|
|
|
* @param aDirectoryList a list of directories |
|
|
|
|
|
* @param aRemotePath the remote path |
|
|
|
|
|
* @param preserveLastModified True if the last modified time needs to be preserved |
|
|
|
|
|
* on the transferred files. False otherwise. |
|
|
|
|
|
* @since Ant 1.9.10 |
|
|
|
|
|
*/ |
|
|
|
|
|
public ScpToMessageBySftp(final boolean verbose, |
|
|
|
|
|
final Session session, |
|
|
|
|
|
final List aDirectoryList, |
|
|
|
|
|
final String aRemotePath, |
|
|
|
|
|
final boolean preserveLastModified) { |
|
|
|
|
|
this(verbose, session, aRemotePath, preserveLastModified); |
|
|
|
|
|
|
|
|
this.directoryList = aDirectoryList; |
|
|
this.directoryList = aDirectoryList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor for ScpToMessage. |
|
|
* Constructor for ScpToMessage. |
|
|
* @param verbose if true do verbose logging |
|
|
* @param verbose if true do verbose logging |
|
|
* @param session the scp session to use |
|
|
* @param session the scp session to use |
|
|
* @param aRemotePath the remote path |
|
|
* @param aRemotePath the remote path |
|
|
* @since Ant 1.6.2 |
|
|
|
|
|
|
|
|
* @param preserveLastModified True if the last modified time needs to be preserved |
|
|
|
|
|
* on the transferred files. False otherwise. |
|
|
*/ |
|
|
*/ |
|
|
private ScpToMessageBySftp(final boolean verbose, |
|
|
private ScpToMessageBySftp(final boolean verbose, |
|
|
final Session session, |
|
|
final Session session, |
|
|
final String aRemotePath) { |
|
|
|
|
|
|
|
|
final String aRemotePath, |
|
|
|
|
|
final boolean preserveLastModified) { |
|
|
super(verbose, session); |
|
|
super(verbose, session); |
|
|
this.remotePath = aRemotePath; |
|
|
this.remotePath = aRemotePath; |
|
|
|
|
|
this.preserveLastModified = preserveLastModified; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -266,6 +309,14 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { |
|
|
log("Setting file mode '" + Integer.toOctalString(getFileMode()) + "' on remote path " + transferredFileRemotePath); |
|
|
log("Setting file mode '" + Integer.toOctalString(getFileMode()) + "' on remote path " + transferredFileRemotePath); |
|
|
} |
|
|
} |
|
|
channel.chmod(getFileMode(), transferredFileRemotePath); |
|
|
channel.chmod(getFileMode(), transferredFileRemotePath); |
|
|
|
|
|
if (getPreserveLastModified()) { |
|
|
|
|
|
// set the last modified time (seconds since epoch) on the transferred file |
|
|
|
|
|
final int lastModifiedTime = (int) (localFile.lastModified() / 1000L); |
|
|
|
|
|
if (this.getVerbose()) { |
|
|
|
|
|
log("Setting last modified time on remote path " + transferredFileRemotePath + " to " + lastModifiedTime); |
|
|
|
|
|
} |
|
|
|
|
|
channel.setMtime(transferredFileRemotePath, lastModifiedTime); |
|
|
|
|
|
} |
|
|
} finally { |
|
|
} finally { |
|
|
if (this.getVerbose()) { |
|
|
if (this.getVerbose()) { |
|
|
final long endTime = System.currentTimeMillis(); |
|
|
final long endTime = System.currentTimeMillis(); |
|
@@ -289,4 +340,14 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { |
|
|
public String getRemotePath() { |
|
|
public String getRemotePath() { |
|
|
return remotePath; |
|
|
return remotePath; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Returns true if the last modified time needs to be preserved on the |
|
|
|
|
|
* file(s) that get transferred. Returns false otherwise. |
|
|
|
|
|
* |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public boolean getPreserveLastModified() { |
|
|
|
|
|
return this.preserveLastModified; |
|
|
|
|
|
} |
|
|
} |
|
|
} |