Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.8.5
99571a2f4051a63e96aa41d960179f50ec9f7955
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.3
version = 3.8.5
runner.dialect = Scala213Source3

newlines.alwaysBeforeElseAfterCurlyIf = false
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/Streams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private[benji] object Streams {
def onPull(): Unit = {
downstreamWaiting = true

if (/*outbuf.isEmpty && */ !hasBeenPulled(in)) pull(in)
if ( /*outbuf.isEmpty && */ !hasBeenPulled(in)) pull(in)
}

setHandlers(in, out, this)
Expand Down Expand Up @@ -189,7 +189,7 @@ private[benji] object Streams {
def onPull(): Unit = {
downstreamWaiting = true

if (/*outbuf.isEmpty && */ !hasBeenPulled(in)) pull(in)
if ( /*outbuf.isEmpty && */ !hasBeenPulled(in)) pull(in)
}

setHandlers(in, out, this)
Expand Down
5 changes: 3 additions & 2 deletions core/src/test/scala/ErrorCommonSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ trait ErrorCommonSpec extends BenjiMatchers {
{
nonExistingBucket must notExistsIn(storage, 0, 3.seconds)
} and {
existingBucket.create(failsIfExists = true) must beTypedEqualTo({})
.await(1, 5.seconds)
existingBucket.create(failsIfExists =
true
) must beTypedEqualTo({}).await(1, 5.seconds)

} and {
existingBucket must existsIn(
Expand Down
10 changes: 6 additions & 4 deletions core/src/test/scala/StorageCommonSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ trait StorageCommonSpec extends BenjiMatchers with ErrorCommonSpec {

bucket must notExistsIn(storage, 1, 10.seconds) and {
// creating bucket
bucket.create(failsIfExists = true) must beTypedEqualTo({})
.await(2, 3.seconds)
bucket.create(failsIfExists =
true
) must beTypedEqualTo({}).await(2, 3.seconds)

} and {
bucket must existsIn(storage, rwConsistencyRetry, rwConsistencyDuration)
Expand Down Expand Up @@ -376,8 +377,9 @@ trait StorageCommonSpec extends BenjiMatchers with ErrorCommonSpec {
{
bucket must notExistsIn(storage, 1, 10.seconds)
} and {
bucket.create(failsIfExists = true) must beTypedEqualTo({})
.await(2, 5.seconds)
bucket.create(failsIfExists =
true
) must beTypedEqualTo({}).await(2, 5.seconds)
} and {
bucket must existsIn(storage, 2, 7.seconds)
} and {
Expand Down
11 changes: 6 additions & 5 deletions core/src/test/scala/VersioningCommonSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ trait VersioningCommonSpec extends BenjiMatchers with ErrorCommonSpec {
({
bucket must notExistsIn(storage, 1, 3.seconds)
}) and {
bucket.create(failsIfExists = true) must beTypedEqualTo({})
.setMessage("created")
.await(2, 5.seconds)
bucket.create(failsIfExists =
true
) must beTypedEqualTo({}).setMessage("created").await(2, 5.seconds)
} and {
bucket must existsIn(storage, 3, 3.seconds)
} and {
Expand Down Expand Up @@ -276,8 +276,9 @@ trait VersioningCommonSpec extends BenjiMatchers with ErrorCommonSpec {
"to get the content and metadata of a specific version by reference" in {
bucket.versioning must beSome[BucketVersioning].which { vbucket =>
({
bucket.create(failsIfExists = false) must beTypedEqualTo({})
.await(2, 5.seconds)
bucket.create(failsIfExists =
false
) must beTypedEqualTo({}).await(2, 5.seconds)
}) and {
bucket must existsIn(storage, 2, 3.seconds)
.setMessage("bucket before")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ class BenjiController(
}

def deleteObject(bucketName: String, objectName: String) = Action.async {
benji.bucket(bucketName).obj(objectName).delete.ignoreIfNotExists.apply().map {
_ => NoContent
}
benji
.bucket(bucketName)
.obj(objectName)
.delete
.ignoreIfNotExists
.apply()
.map { _ => NoContent }
}
}
87 changes: 47 additions & 40 deletions google/src/main/scala/GoogleObjectRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -598,50 +598,57 @@ final class GoogleObjectRef private[google] (
): Source[VersionedObject, NotUsed] = {
implicit val ec: ExecutionContext = m.executionContext

Source.fromFutureSource(Future {
val prepared =
gt.client.objects().list(bucket).setVersions(true).setPrefix(name)
val maxed = maybeMax.fold(prepared) { prepared.setMaxResults(_) }

val request =
nextToken.fold(maxed.execute()) { maxed.setPageToken(_).execute() }

val (currentPage, empty) = Option(request.getItems) match {
case Some(items) =>
val collection = items.asScala.filter(_.getName == name)
val source = Source.fromIterator[VersionedObject] { () =>
collection.iterator.map { (obj: StorageObject) =>
VersionedObject(
obj.getName,
Bytes(obj.getSize.longValue),
LocalDateTime.ofInstant(
Instant.ofEpochMilli(obj.getUpdated.getValue),
ZoneOffset.UTC
),
obj.getGeneration.toString,
obj.getTimeDeleted == null
)
Source.fromFutureSource(
Future {
val prepared =
gt.client.objects().list(bucket).setVersions(true).setPrefix(name)
val maxed = maybeMax.fold(prepared) { prepared.setMaxResults(_) }

val request =
nextToken.fold(maxed.execute()) { maxed.setPageToken(_).execute() }

val (currentPage, empty) = Option(request.getItems) match {
case Some(items) =>
val collection = items.asScala.filter(_.getName == name)
val source = Source.fromIterator[VersionedObject] { () =>
collection.iterator.map { (obj: StorageObject) =>
VersionedObject(
obj.getName,
Bytes(obj.getSize.longValue),
LocalDateTime.ofInstant(
Instant.ofEpochMilli(obj.getUpdated.getValue),
ZoneOffset.UTC
),
obj.getGeneration.toString,
obj.getTimeDeleted == null
)
}
}
}
(source, collection.isEmpty)
(source, collection.isEmpty)

case _ => (Source.empty[VersionedObject], true)
}
case _ => (Source.empty[VersionedObject], true)
}

Option(request.getNextPageToken) match {
case nextPageToken @ Some(_) =>
currentPage ++ apply(
nextPageToken,
maybeEmpty = maybeEmpty && empty
)
Option(request.getNextPageToken) match {
case nextPageToken @ Some(_) =>
currentPage ++ apply(
nextPageToken,
maybeEmpty = maybeEmpty && empty
)

case _ =>
if (maybeEmpty && empty)
throw ObjectNotFoundException(ref)
else
currentPage
}
}.recoverWith(ErrorHandler.ofObjectToFuture(s"Could not list versions of object $name inside bucket $bucket", ref)))
case _ =>
if (maybeEmpty && empty)
throw ObjectNotFoundException(ref)
else
currentPage
}
}.recoverWith(
ErrorHandler.ofObjectToFuture(
s"Could not list versions of object $name inside bucket $bucket",
ref
)
)
)
}.mapMaterializedValue(_ => NotUsed)

def apply(
Expand Down
5 changes: 3 additions & 2 deletions google/src/test/scala/GoogleStorageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ final class GoogleStorageSpec(
lazy val gbucket = google.bucket(bucketName)

s"Create another bucket $bucketName" in {
gbucket.create(failsIfExists = true) must beTypedEqualTo({})
.await(0, 5.seconds)
gbucket.create(failsIfExists =
true
) must beTypedEqualTo({}).await(0, 5.seconds)
}

val objName = "testfile.txt"
Expand Down
5 changes: 2 additions & 3 deletions s3/src/main/scala/WSS3VersionedObjectRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@ final class WSS3VersionedObjectRef(

if (skipMarkers) multiDeleteSimulated(Seq(self))
else
markersToDelete().flatMap(markers =>
multiDeleteSimulated(self +: markers)
)
markersToDelete()
.flatMap(markers => multiDeleteSimulated(self +: markers))
}

def ignoreIfNotExists: WSS3DeleteRequest = copy(ignoreExists = true)
Expand Down