From 45c5da67af99cd20957f5db281887eaa26ccde5c Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Tue, 21 Feb 2023 13:39:35 -0500 Subject: [PATCH] updates --- build.gradle.kts | 8 ++-- .../s3/s34k/minio/BucketObjectContainer.kt | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f4d291f..5345b10 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.6.20" - id("org.jetbrains.dokka") version "1.6.10" + kotlin("jvm") version "1.8.0" + id("org.jetbrains.dokka") version "1.7.20" `java-library` `maven-publish` } group = "org.veupathdb.lib.s3" -version = "0.3.6+s34k-0.7.2" +version = "0.4.0+s34k-0.8.0" java { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -39,7 +39,7 @@ dependencies { implementation("io.minio:minio:8.4.5") @Suppress("GradlePackageVersionRange") - api("org.veupathdb.lib.s3:s34k-core:0.6.1+s34k-0.7.2") + api("org.veupathdb.lib.s3:s34k-core:0.7.0+s34k-0.8.0") testImplementation(kotlin("test")) } diff --git a/src/main/kotlin/org/veupathdb/lib/s3/s34k/minio/BucketObjectContainer.kt b/src/main/kotlin/org/veupathdb/lib/s3/s34k/minio/BucketObjectContainer.kt index 7be79e8..b883220 100644 --- a/src/main/kotlin/org/veupathdb/lib/s3/s34k/minio/BucketObjectContainer.kt +++ b/src/main/kotlin/org/veupathdb/lib/s3/s34k/minio/BucketObjectContainer.kt @@ -15,6 +15,7 @@ import org.veupathdb.lib.s3.s34k.* import org.veupathdb.lib.s3.s34k.buckets.S3Bucket import org.veupathdb.lib.s3.s34k.core.objects.AbstractObjectContainer import org.veupathdb.lib.s3.s34k.core.objects.BasicObjectList +import org.veupathdb.lib.s3.s34k.core.objects.BasicSubPathListing import org.veupathdb.lib.s3.s34k.errors.MultiObjectDeleteError import org.veupathdb.lib.s3.s34k.errors.ObjectDeleteError import org.veupathdb.lib.s3.s34k.errors.S34KError @@ -32,6 +33,7 @@ import org.veupathdb.lib.s3.s34k.params.`object`.directory.DirectoryDeleteParams import org.veupathdb.lib.s3.s34k.params.`object`.multi.MultiObjectDeleteParams import org.veupathdb.lib.s3.s34k.params.`object`.touch.ObjectTouchParams import java.time.OffsetDateTime +import kotlin.streams.toList internal class BucketObjectContainer( private val bucket: S3Bucket, @@ -309,6 +311,41 @@ internal class BucketObjectContainer( } } + override fun listSubPaths(params: SubPathListParams): SubPathListing { + log.debug("Attempting to list sub-paths under prefix {} with delimiter {} in bucket {}", params.prefix, params.delimiter, bucket) + + return try { + val prefixes = ArrayList(100) + val objects = minio.listObjects(ListObjectsArgs.builder() + .bucket(bucket) + .region(params, bucket) + .recursive(true) + .prefix(params.prefix) + .delimiter(params.delimiter) + .headers(params.headers) + .queryParams(params.queryParams) + .build()) + .toStream() + .map(Result::get) + .peek { if (it.isDir) prefixes.add(it.objectName()) } + .filter { !it.isDir } + .map { MObject( + it.objectName(), + it.lastModified().toOffsetDateTime(), + it.etag(), + bucket.region, + MHeaders(), + bucket, + minio + ) } + .toIterable() + + BasicSubPathListing(BasicObjectList(objects), prefixes) + } catch (e: Throwable) { + e.throwCorrect { "Failed to fetch sub-path list from bucket $bucket" } + } + } + override fun open(path: String, params: ObjectOpenParams): StreamObject? { log.debug("Attempting to open object '{}' in {}", path, bucket)