Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ListMultipartUpload token only has one token defined #2749

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ import scala.concurrent.{ExecutionContext, Future}
val baseQuery = Seq(
"prefix" -> prefix,
"delimiter" -> delimiter,
"key-marker" -> continuationToken.map(_.nextKeyMarker),
"upload-id-marker" -> continuationToken.map(_.nextUploadIdMarker)
"key-marker" -> continuationToken.flatMap(_.nextKeyMarker),
"upload-id-marker" -> continuationToken.flatMap(_.nextUploadIdMarker)
).collect { case (k, Some(v)) => k -> v }.toMap

// We need to manually construct a query here because the Uri for getting a list of multipart uploads requires a
Expand Down
15 changes: 8 additions & 7 deletions s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ import scala.util.{Failure, Success, Try}
commonPrefixes: Seq[ListBucketResultCommonPrefixes])

/** Internal Api */
@InternalApi private[impl] final case class ListMultipartUploadContinuationToken(nextKeyMarker: String,
nextUploadIdMarker: String)
@InternalApi private[impl] final case class ListMultipartUploadContinuationToken(nextKeyMarker: Option[String],
nextUploadIdMarker: Option[String])

/** Internal Api */
@InternalApi private[impl] final case class ListMultipartUploadsResult(
Expand All @@ -96,13 +96,14 @@ import scala.util.{Failure, Success, Try}

/**
* The continuation token for listing MultipartUpload is a union of both the nextKeyMarker
* and the nextUploadIdMarker
* and the nextUploadIdMarker. Even though both `nextKeyMarker` and `nextUploadIdMarker` should be
* defined (if applicable), for safety reasons we also handle the case where one is defined and not the other.
*/
def continuationToken: Option[ListMultipartUploadContinuationToken] =
for {
keyMarker <- nextKeyMarker
uploadIdMarker <- nextUploadIdMarker
} yield ListMultipartUploadContinuationToken(keyMarker, uploadIdMarker)
(nextKeyMarker, nextUploadIdMarker) match {
case (None, None) => None
case (key, uploadId) => Some(ListMultipartUploadContinuationToken(key, uploadId))
}

}

Expand Down