Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed May 9, 2022
1 parent 32be7eb commit ddb78ee
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,28 +263,23 @@ internal class BucketObjectContainer(
override fun list(params: ObjectListParams): ObjectList {
log.debug("Attempting to list objects in {}", bucket)

val res = try {
minio.listObjects(ListObjectsArgs.builder()
.bucket(bucket)
.region(params, bucket)
.recursive(true)
.optPrefix(params.region)
.headers(params.headers)
.queryParams(params.queryParams)
.build())
.toStream()
.map(Result<Item>::get)
return try {
BasicObjectList(
minio.listObjects(ListObjectsArgs.builder()
.bucket(bucket)
.region(params, bucket)
.recursive(true)
.optPrefix(params.region)
.headers(params.headers)
.queryParams(params.queryParams)
.build())
.toStream()
.map(Result<Item>::get)
.map { MObject(it.objectName(), bucket.region, MHeaders(), bucket, minio) }
.toIterable())
} catch (e: Throwable) {
e.throwCorrect { "Failed to fetch object list from $bucket" }
}

// If they set the recursive flag, then we are gonna given them all of it.
if (params.recursive) {
return BasicObjectList(res.map{ MObject(it.objectName(), bucket.region, MHeaders(), bucket, minio) }.toIterable())
}

// They didn't set the recursive flag, so we have some work to do
val pref = if (params.prefix.isNullOrBlank()) 0
}

override fun open(path: String, params: ObjectOpenParams): StreamObject? {
Expand Down

0 comments on commit ddb78ee

Please sign in to comment.