Created
February 22, 2021 14:58
-
-
Save conorgriffin/db1b2c92c846722e5fc72407aeca6fed to your computer and use it in GitHub Desktop.
SSHJ's SFTPFileTransfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private LocalDestFile downloadFile(final StreamCopier.Listener listener, | |
final RemoteResourceInfo remote, | |
final LocalDestFile local) | |
throws IOException { | |
final LocalDestFile adjusted = local.getTargetFile(remote.getName()); | |
final RemoteFile rf = engine.open(remote.getPath()); | |
try { | |
final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); | |
final OutputStream os = adjusted.getOutputStream(); | |
try { | |
new StreamCopier(rfis, os, engine.getLoggerFactory()) | |
.bufSize(engine.getSubsystem().getLocalMaxPacketSize()) | |
.keepFlushing(false) | |
.listener(listener) | |
.copy(); | |
} finally { | |
rfis.close(); | |
os.close(); | |
} | |
} finally { | |
rf.close(); | |
} | |
return adjusted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment