/** * Carry out the transfer. * @throws IOException on i/o errors * @throws JSchException on errors detected by scp */ @Override public void execute() throws IOException, JSchException { if (directoryList != null) { doMultipleTransfer(); } if (localFile != null) { doSingleTransfer(); } log("done.\n"); }
private void sendDirectoryToRemote(final Directory directory, final InputStream in, final OutputStream out) throws IOException { String command = "D0"; command += Integer.toOctalString(getDirMode()); command += " 0 "; command += directory.getDirectory().getName(); command += "\n"; out.write(command.getBytes()); out.flush(); waitForAck(in); sendDirectory(directory, in, out); out.write("E\n".getBytes()); out.flush(); waitForAck(in); }
if (getPreserveLastModified()) { String command = "T" + (localFile.lastModified() / 1000) + " 0"; command += " " + (localFile.lastModified() / 1000) + " 0\n"; waitForAck(in); command += Integer.toOctalString(getFileMode()); command += " " + filesize + " "; command += localFile.getName(); waitForAck(in); final boolean trackProgress = getVerbose() && filesize > HUNDRED_KILOBYTES; if (this.getVerbose()) { log("Sending: " + localFile.getName() + " : " + localFile.length()); percentTransmitted = trackProgress(initFilesize, totalLength, percentTransmitted); sendAck(out); waitForAck(in); } finally { if (this.getVerbose()) { final long endTime = System.currentTimeMillis(); logStats(startTime, endTime, totalLength);
ScpToMessage message; if (!isSftp) { message = new ScpToMessage(getVerbose(), compressed, session, list, file, preserveLastModified); } else { list, file, preserveLastModified); message.setLogListener(this); if (fileMode != null) { message.setFileMode(fileMode); message.setDirMode(dirMode); message.execute();
private void doSingleTransfer() throws IOException, JSchException { StringBuilder sb = new StringBuilder("scp -t "); if (getPreserveLastModified()) { sb.append("-p "); } if (getCompressed()) { sb.append("-C "); } sb.append(remotePath); final String cmd = sb.toString(); final Channel channel = openExecChannel(cmd); try { final OutputStream out = channel.getOutputStream(); final InputStream in = channel.getInputStream(); channel.connect(); waitForAck(in); sendFileToRemote(localFile, in, out); } finally { if (channel != null) { channel.disconnect(); } } }
private void doMultipleTransfer() throws IOException, JSchException { StringBuilder sb = new StringBuilder("scp -r -d -t "); if (getPreserveLastModified()) { sb.append("-p "); } if (getCompressed()) { sb.append("-C "); } sb.append(remotePath); final Channel channel = openExecChannel(sb.toString()); try { final OutputStream out = channel.getOutputStream(); final InputStream in = channel.getInputStream(); channel.connect(); waitForAck(in); for (Directory current : directoryList) { sendDirectory(current, in, out); } } finally { if (channel != null) { channel.disconnect(); } } }
if (!isSftp) { message = new ScpToMessage(getVerbose(), compressed, session, getProject().resolveFile(fromPath), file, preserveLastModified); file, preserveLastModified); message.setLogListener(this); if (fileMode != null) { message.setFileMode(fileMode); message.setDirMode(dirMode); message.execute(); } finally { if (session != null) {