Skip to content

Commit

Permalink
Merge pull request #5 from VEuPathDB/v0.2.0-dev
Browse files Browse the repository at this point in the history
v0.2.0 - Targeted object list
  • Loading branch information
Foxcapades authored May 9, 2022
2 parents f3fdebe + f17a65c commit 45e1451
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "org.veupathdb.lib.s3"
version = "0.1.0+s34k-0.3.0"
version = "0.2.0+s34k-0.4.0"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -36,9 +36,10 @@ dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("io.minio:minio:8.3.8")
implementation("io.minio:minio:8.3.9")

api("org.veupathdb.lib.s3:s34k-core:0.2.0+s34k-0.3.0")
@Suppress("GradlePackageVersionRange")
api("org.veupathdb.lib.s3:s34k-core:0.3.0+s34k-0.4.0")

testImplementation(kotlin("test"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ internal class BucketObjectContainer(
return out
}

override fun listAll(params: ObjectListParams): ObjectList {
override fun listAll(params: ObjectListAllParams): ObjectList {
log.debug("Attempting to list all objects in {}", bucket)

val out = try {
Expand All @@ -260,6 +260,28 @@ internal class BucketObjectContainer(
return out
}

override fun list(params: ObjectListParams): ObjectList {
log.debug("Attempting to list objects in {}", bucket)

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" }
}
}

override fun open(path: String, params: ObjectOpenParams): StreamObject? {
log.debug("Attempting to open object '{}' in {}", path, bucket)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ internal inline fun <B: ObjectArgs.Builder<B, A>, A: ObjectArgs> B.region(params

// endregion Object Args

internal inline fun ListObjectsArgs.Builder.optPrefix(prefix: String?) = also { prefix?.let(this::prefix) }
internal inline fun ListObjectsArgs.Builder.optPrefix(prefix: String?) =
also { if (!prefix.isNullOrBlank()) prefix(prefix) }


internal inline fun PutObjectArgs.Builder.optContentType(ct: String?) = also { ct?.let(this::contentType) }
Expand Down
3 changes: 2 additions & 1 deletion test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("io.minio:minio:8.3.9")

implementation("org.veupathdb.lib.s3:s34k-minio:0.1.0")
implementation("org.veupathdb.lib.s3:s34k-minio:0.2.0+s34k-0.4.0")

implementation("org.apache.logging.log4j:log4j-core:2.17.2")
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.2")
Expand Down
2 changes: 1 addition & 1 deletion test/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AppenderRef ref="STDOUT" />
</Root>

<Logger name="org.veupathdb.lib.s3.s34k" level="debug" additivity="false">
<Logger name="org.veupathdb.lib.s3.s34k" level="off" additivity="false">
<AppenderRef ref="STDOUT" />
</Logger>
</Loggers>
Expand Down

0 comments on commit 45e1451

Please sign in to comment.