Skip to content

Commit

Permalink
refactor(ort-utils): Remove some superfluous apply statements
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Feb 20, 2024
1 parent fed338e commit 4b7573e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions utils/ort/src/main/kotlin/storage/S3FileStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class S3FileStorage(
}

if (awsRegion != null && provider != null) {
S3Client.builder().apply {
region(Region.of(awsRegion))
credentialsProvider(provider)
endpointOverride(if (customEndpoint != null) URI.create(customEndpoint) else null)
}.build()
S3Client.builder()
.region(Region.of(awsRegion))
.credentialsProvider(provider)
.endpointOverride(if (customEndpoint != null) URI.create(customEndpoint) else null)
.build()
} else {
if (awsRegion != null) {
S3Client.builder().region(Region.of(awsRegion)).build()
Expand All @@ -87,10 +87,10 @@ class S3FileStorage(
}

override fun exists(path: String): Boolean {
val request = HeadObjectRequest.builder().apply {
key(path)
bucket(bucketName)
}.build()
val request = HeadObjectRequest.builder()
.key(path)
.bucket(bucketName)
.build()

return runCatching { s3Client.headObject(request) }.onFailure { exception ->
if (exception !is NoSuchKeyException) {
Expand All @@ -100,10 +100,10 @@ class S3FileStorage(
}

override fun read(path: String): InputStream {
val request = GetObjectRequest.builder().apply {
key(path)
bucket(bucketName)
}.build()
val request = GetObjectRequest.builder()
.key(path)
.bucket(bucketName)
.build()

return runCatching {
val response = s3Client.getObjectAsBytes(request)
Expand All @@ -115,10 +115,10 @@ class S3FileStorage(
}

override fun write(path: String, inputStream: InputStream) {
val request = PutObjectRequest.builder().apply {
key(path)
bucket(bucketName)
}.build()
val request = PutObjectRequest.builder()
.key(path)
.bucket(bucketName)
.build()

val body = inputStream.use {
if (compression) {
Expand Down

0 comments on commit 4b7573e

Please sign in to comment.