diff --git a/.gitignore b/.gitignore index baaad1f5..86c23752 100644 --- a/.gitignore +++ b/.gitignore @@ -408,7 +408,7 @@ project/plugins/project/ *.log .metals/ -project/metals.sbt +metals.sbt .bloop/ project/secret @@ -420,3 +420,5 @@ website/static/api #minio .minio.sys/ + +.vscode/ diff --git a/build.sbt b/build.sbt index 36d73775..c59070d1 100644 --- a/build.sbt +++ b/build.sbt @@ -22,8 +22,8 @@ inThisBuild( addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck") -val zioVersion = "1.0.5" -val awsVersion = "2.16.37" +val zioVersion = "1.0.6" +val awsVersion = "2.16.61" lazy val `zio-s3` = project .in(file(".")) diff --git a/src/main/scala/zio/s3/Live.scala b/src/main/scala/zio/s3/Live.scala index c782e3e2..d829c935 100644 --- a/src/main/scala/zio/s3/Live.scala +++ b/src/main/scala/zio/s3/Live.scala @@ -101,7 +101,14 @@ final class Live(unsafeClient: S3AsyncClient) extends S3.Service { ZIO.succeed(listing.copy(nextContinuationToken = None, objectSummaries = Chunk.empty)) ) { token => execute( - _.listObjectsV2(ListObjectsV2Request.builder().bucket(listing.bucketName).continuationToken(token).build()) + _.listObjectsV2( + ListObjectsV2Request + .builder() + .bucket(listing.bucketName) + .continuationToken(token) + .prefix(listing.prefix.orNull) + .build() + ) ).map(S3ObjectListing.fromResponse) } diff --git a/src/main/scala/zio/s3/Test.scala b/src/main/scala/zio/s3/Test.scala index f68174c0..eb4169be 100644 --- a/src/main/scala/zio/s3/Test.scala +++ b/src/main/scala/zio/s3/Test.scala @@ -143,10 +143,11 @@ object Test { options.delimiter, options.starAfter, list.take(options.maxKeys.toInt), - Some(UUID.randomUUID().toString) + Some(UUID.randomUUID().toString), + None ) case list => - S3ObjectListing(bucketName, options.delimiter, options.starAfter, list, None) + S3ObjectListing(bucketName, options.delimiter, options.starAfter, list, None, None) } .orDie .provide(blocking) diff --git a/src/main/scala/zio/s3/package.scala b/src/main/scala/zio/s3/package.scala index 779ec8b3..cb6d24f2 100644 --- a/src/main/scala/zio/s3/package.scala +++ b/src/main/scala/zio/s3/package.scala @@ -184,8 +184,8 @@ package object s3 { */ def paginate(initialListing: S3ObjectListing): Stream[S3Exception, S3ObjectListing] = ZStream.paginateM(initialListing) { - case current @ S3ObjectListing(_, _, _, _, None) => ZIO.succeed(current -> None) - case current => self.getNextObjects(current).map(next => current -> Some(next)) + case current @ S3ObjectListing(_, _, _, _, None, _) => ZIO.succeed(current -> None) + case current => self.getNextObjects(current).map(next => current -> Some(next)) } /** diff --git a/src/main/scala/zio/s3/s3model.scala b/src/main/scala/zio/s3/s3model.scala index 68959dea..22a89634 100644 --- a/src/main/scala/zio/s3/s3model.scala +++ b/src/main/scala/zio/s3/s3model.scala @@ -40,13 +40,14 @@ final case class S3ObjectListing( delimiter: Option[String], starAfter: Option[String], objectSummaries: Chunk[S3ObjectSummary], - nextContinuationToken: Option[String] + nextContinuationToken: Option[String], + prefix: Option[String] ) object S3ObjectListing { def from(bucketName: String, nextContinuationToken: Option[String]) = - S3ObjectListing(bucketName, None, None, Chunk.empty, nextContinuationToken) + S3ObjectListing(bucketName, None, None, Chunk.empty, nextContinuationToken, None) def fromResponse(r: ListObjectsV2Response): S3ObjectListing = S3ObjectListing( @@ -56,8 +57,10 @@ object S3ObjectListing { Chunk .fromIterable(r.contents().asScala.toList) .map(o => S3ObjectSummary(r.name(), o.key(), o.lastModified(), o.size())), - Option(r.nextContinuationToken()) + Option(r.nextContinuationToken()), + Option(r.prefix()).collect { case x if x.nonEmpty => x } ) + } final case class S3ObjectSummary(bucketName: String, key: String, lastModified: Instant, size: Long)