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..792a1f9f 100644 --- a/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala +++ b/zio-ftp/src/main/scala/zio/ftp/SecureFtp.scala @@ -116,12 +116,12 @@ final private class SecureFtp(unsafeClient: Client) extends FtpAccessors[Client] object SecureFtp { type Client = SFTPClient - def apply(unsafeClient: Client): URIO[Scope, FtpAccessors[Client]] = - acquireRelease(ZIO.succeed(new SecureFtp(unsafeClient)))(cli => - cli - .execute(_.close()) - .ignore - ) + def connect(unsafeSsh: SSHClient): ZIO[Scope, ConnectionError, FtpAccessors[Client]] = + acquireRelease( + attemptBlockingIO( + new SecureFtp(unsafeSsh.newSFTPClient()) + ).mapError(error => ConnectionError(error.getMessage, error)) + )(_.execute(_.close()).ignore) def connect(settings: SecureFtpSettings): ZIO[Scope, ConnectionError, FtpAccessors[Client]] = { val ssh = new SSHClient(settings.sshConfig) 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(