Skip to content

Commit

Permalink
refactor bucket match
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Nowak <[email protected]>
  • Loading branch information
twrichards and andrew-nowak authored Jul 31, 2023
1 parent a7aa975 commit 0f094ef
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions image-loader/app/model/Projector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,16 @@ class Projector(config: ImageUploadOpsCfg,
val s3Key = fileKeyFromId(imageId)

val bucket = config.maybeReplicaBucket match {
case Some(replicaBucket) if !s3.doesObjectExist(config.originalFileBucket, s3Key) =>
case _ if s3.doesObjectExist(config.originalFileBucket, s3Key) =>
config.originalFileBucket
case Some(replicaBucket) if s3.doesObjectExist(replicaBucket, s3Key) =>
replicaBucket
case _ =>
config.originalFileBucket
}

if (config.maybeReplicaBucket.contains(bucket) && !s3.doesObjectExist(bucket, s3Key)) {
logger.error(
logMarker,
s"Image with id $imageId does not exist at key $s3Key in S3 bucket ${config.originalFileBucket}${config.maybeReplicaBucket.map(rb => s" NOR replica bucket $rb")}"
)
throw new NoSuchImageExistsInS3(bucket, s3Key)
logger.error(
logMarker,
s"Image with id $imageId does not exist at key $s3Key in S3 bucket ${config.originalFileBucket}${config.maybeReplicaBucket.map(rb => s" NOR replica bucket $rb")}"
)
throw new NoSuchImageExistsInS3(config.originalFileBucket, s3Key)
}

val s3Source = Stopwatch(s"object exists, getting s3 object at s3://$bucket/$s3Key to perform Image projection"){
Expand Down

0 comments on commit 0f094ef

Please sign in to comment.