Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Feb 21, 2023
1 parent a994fe9 commit 45c5da6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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<String>(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<Item>::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)

Expand Down

0 comments on commit 45c5da6

Please sign in to comment.