Skip to content

Instantly share code, notes, and snippets.

@conorgriffin
Created February 22, 2021 14:51
Show Gist options
  • Save conorgriffin/39b52000a350886ef556100bca5c4d10 to your computer and use it in GitHub Desktop.
Save conorgriffin/39b52000a350886ef556100bca5c4d10 to your computer and use it in GitHub Desktop.
FtpIOGraphStage - Multiple Read Requests
protected[this] def doPreStart(): Unit =
isOpt = ftpLike match {
case ur: UnconfirmedReads =>
withUnconfirmedReads(ur)
case ro: RetrieveOffset =>
Some(ro.retrieveFileInputStream(path, handler.get.asInstanceOf[ro.Handler], offset).get)
case _ =>
Some(ftpLike.retrieveFileInputStream(path, handler.get).get)
}
private def withUnconfirmedReads(
ftpLikeWithUnconfirmedReads: FtpLike[FtpClient, S] with UnconfirmedReads
): Option[InputStream] =
connectionSettings match {
case s: SftpSettings =>
Some(
ftpLikeWithUnconfirmedReads
.retrieveFileInputStream(path,
handler.get.asInstanceOf[ftpLikeWithUnconfirmedReads.Handler],
offset,
s.maxUnconfirmedReads)
.get
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment