From 648835b730467953ed13341658ad869c974aad80 Mon Sep 17 00:00:00 2001 From: regis-leray Date: Mon, 7 Aug 2023 16:26:51 -0400 Subject: [PATCH] 356 - update dependencies --- .github/workflows/site.yml | 2 +- project/plugins.sbt | 8 ++++---- zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala | 2 +- zio-ftp/src/main/scala/zio/ftp/UnsecureFtp.scala | 11 +++++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 223121b5..7cc15f37 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -62,7 +62,7 @@ jobs: generate-readme: name: Generate README runs-on: ubuntu-latest - if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event_name == 'published')) }} + if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event.action == 'published')) }} steps: - name: Git Checkout uses: actions/checkout@v3.3.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index f708baf7..d6754641 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.9") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.29") -addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.5") +addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.10") diff --git a/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala b/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala index b6cae2b2..55ec3d37 100644 --- a/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala +++ b/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala @@ -116,7 +116,7 @@ final private class SecureFtp(unsafeClient: Client) extends FtpAccessors[Client] object SecureFtp { type Client = SFTPClient - def apply(unsafeClient: Client): URIO[Scope, FtpAccessors[Client]] = + def connect(unsafeClient: Client, credentials: FtpCredentials): URIO[Scope, FtpAccessors[Client]] = acquireRelease(ZIO.succeed(new SecureFtp(unsafeClient)))(cli => cli .execute(_.close()) diff --git a/zio-ftp/src/main/scala/zio/ftp/UnsecureFtp.scala b/zio-ftp/src/main/scala/zio/ftp/UnsecureFtp.scala index 31e69ceb..3838ed81 100644 --- a/zio-ftp/src/main/scala/zio/ftp/UnsecureFtp.scala +++ b/zio-ftp/src/main/scala/zio/ftp/UnsecureFtp.scala @@ -102,10 +102,13 @@ final private class UnsecureFtp(unsafeClient: Client) extends FtpAccessors[Clien object UnsecureFtp { type Client = JFTPClient - def apply(unsafeClient: Client): URIO[Scope, FtpAccessors[Client]] = - acquireRelease(ZIO.succeed(new UnsecureFtp(unsafeClient))) { client => - client.execute(_.logout()).ignore *> client.execute(_.disconnect()).ignore - } + def connect(unsafeClient: Client, credentials: FtpCredentials): ZIO[Scope, ConnectionError, FtpAccessors[Client]] = + acquireRelease(for{ + client <- ZIO.succeed(new UnsecureFtp(unsafeClient)) + _ <- client.execute(_.login(credentials.username, credentials.password)) + .mapError(error => ConnectionError(error.getMessage, error)) + .filterOrFail(identity)(ConnectionError("Cannot connect to the server")) + } yield client)(client => client.execute(_.logout()).ignore *> client.execute(_.disconnect()).ignore) def connect(settings: UnsecureFtpSettings): ZIO[Scope, ConnectionError, FtpAccessors[Client]] = acquireRelease(