Skip to content

Commit

Permalink
ftp: Scala 3 (#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru authored Oct 23, 2023
1 parent ff322ae commit c5a3c7c
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ lazy val ftp = alpakkaProject(
"ftp",
"ftp",
Dependencies.Ftp,
Scala3.settings,
Test / fork := true,
// To avoid potential blocking in machines with low entropy (default is `/dev/random`)
Test / javaOptions += "-Djava.security.egd=file:/dev/./urandom"
Expand Down
4 changes: 2 additions & 2 deletions ftp/src/main/scala/akka/stream/alpakka/ftp/impl/FtpLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected[ftp] trait FtpLike[FtpClient, S <: RemoteFileSettings] {
* INTERNAL API
*/
@InternalApi
protected[ftp] trait RetrieveOffset { _: FtpLike[_, _] =>
protected[ftp] trait RetrieveOffset { ftpLike: FtpLike[_, _] =>

def retrieveFileInputStream(name: String, handler: Handler, offset: Long): Try[InputStream]

Expand All @@ -55,7 +55,7 @@ protected[ftp] trait RetrieveOffset { _: FtpLike[_, _] =>
* INTERNAL API
*/
@InternalApi
protected[ftp] trait UnconfirmedReads { _: FtpLike[_, _] =>
protected[ftp] trait UnconfirmedReads { ftpLike: FtpLike[_, _] =>

def retrieveFileInputStream(name: String, handler: Handler, offset: Long, maxUnconfirmedReads: Int): Try[InputStream]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import scala.util.Try
* INTERNAL API
*/
@InternalApi
private[ftp] trait FtpOperations extends CommonFtpOperations { _: FtpLike[FTPClient, FtpSettings] =>
private[ftp] trait FtpOperations extends CommonFtpOperations { ftpLike: FtpLike[FTPClient, FtpSettings] =>

def connect(connectionSettings: FtpSettings)(implicit ftpClient: FTPClient): Try[Handler] = Try {
connectionSettings.proxy.foreach(ftpClient.setProxy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.util.Try
*/
@InternalApi
private[ftp] trait FtpsOperations extends CommonFtpOperations {
_: FtpLike[FTPSClient, FtpsSettings] =>
ftpLike: FtpLike[FTPSClient, FtpsSettings] =>

def connect(connectionSettings: FtpsSettings)(implicit ftpClient: FTPSClient): Try[Handler] =
Try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.util.{Failure, Try}
* INTERNAL API
*/
@InternalApi
private[ftp] trait SftpOperations { _: FtpLike[SSHClient, SftpSettings] =>
private[ftp] trait SftpOperations { ftpLike: FtpLike[SSHClient, SftpSettings] =>

type Handler = SFTPClient

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.apache.commons.net.ftp.{FTPClient, FTPSClient}
import scala.compat.java8.FunctionConverters._

@DoNotInherit
sealed trait FtpApi[FtpClient, S <: RemoteFileSettings] { _: FtpSourceFactory[FtpClient, S] =>
sealed trait FtpApi[FtpClient, S <: RemoteFileSettings] { factory: FtpSourceFactory[FtpClient, S] =>

/**
* Java API: creates a [[akka.stream.javadsl.Source Source]] of [[FtpFile]]s from the remote user `root` directory.
Expand Down Expand Up @@ -584,6 +584,6 @@ object Sftp extends SftpApi {
*/
def create(customSshClient: SSHClient): SftpApi =
new SftpApi {
override val sshClient: SSHClient = customSshClient
override def sshClient(): SSHClient = customSshClient
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.apache.commons.net.ftp.{FTPClient, FTPSClient}
import scala.concurrent.Future

@DoNotInherit
sealed trait FtpApi[FtpClient, S <: RemoteFileSettings] { _: FtpSourceFactory[FtpClient, S] =>
sealed trait FtpApi[FtpClient, S <: RemoteFileSettings] { factory: FtpSourceFactory[FtpClient, S] =>

/**
* Scala API: creates a [[akka.stream.scaladsl.Source Source]] of [[FtpFile]]s from the remote user `root` directory.
Expand Down Expand Up @@ -398,6 +398,6 @@ object Sftp extends SftpApi {
*/
def apply(customSshClient: SSHClient): SftpApi =
new SftpApi {
override val sshClient: SSHClient = customSshClient
override def sshClient(): SSHClient = customSshClient
}
}
2 changes: 1 addition & 1 deletion ftp/src/test/scala/akka/stream/alpakka/ftp/BaseSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ trait BaseSpec
// Allows to run tests n times in a row with a command line argument, useful for debugging sporadic failures
// e.g. ftp/testOnly *.FtpsStageSpec -- -Dtimes=20
// https://gist.github.com/dwickern/6ba9c5c505d2325d3737ace059302922
override abstract protected def runTest(testName: String, args: Args): Status = {
override protected def runTest(testName: String, args: Args): Status = {
def run0(times: Int): Status = {
val status = super.runTest(testName, args)
if (times <= 1) status else status.thenRun(run0(times - 1))
Expand Down
2 changes: 2 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ object Common extends AutoPlugin {
case Dependencies.Scala213
if insideCI.value && fatalWarnings.value && !Dependencies.CronBuild && scalaVersion.value != Dependencies.Scala3 =>
Seq("-Werror")
case Dependencies.Scala3 if insideCI.value =>
Seq("-explain")
case _ => Seq.empty[String]
}),
Compile / doc / scalacOptions := scalacOptions.value ++ Seq(
Expand Down

0 comments on commit c5a3c7c

Please sign in to comment.