Skip to content

Commit

Permalink
Feature: Handle folders in bucket IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
LaCuneta committed Oct 6, 2022
1 parent 5200b5d commit e6e6318
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val playVersion = "2.8.16"

lazy val sharedSettings = Seq(
organization := "org.nlogo"
, version := "1.0.0"
, version := "1.0.1"
, isSnapshot := true
, licenses += ("Creative Commons Zero v1.0 Universal Public Domain Dedication", url("https://creativecommons.org/publicdomain/zero/1.0/"))
, publishTo := { Some("Cloudsmith API" at "https://maven.cloudsmith.io/netlogo/play-scraper/") }
Expand Down
5 changes: 3 additions & 2 deletions sbt-scrape-plugin/src/main/scala/StaticSiteUploader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ object StaticSiteUploader {
}

def addRedirects(bucketId: String, fileKeys: Seq[String], redirectHost: Option[String], client: AmazonS3Client) = {
val realBucketId = bucketId.split("/")(0)
try {
val redirectToAppropriateHost: RedirectRule => RedirectRule =
redirectHost.map(host => (r: RedirectRule) => r.withHostName(host)).getOrElse(identity _)
Expand All @@ -87,8 +88,8 @@ object StaticSiteUploader {
new RoutingRule()
.withCondition(new RoutingRuleCondition().withKeyPrefixEquals(s"$k/"))
.withRedirect(redirectToAppropriateHost(new RedirectRule().withReplaceKeyWith(k))))
val currentConfiguration = client.getBucketWebsiteConfiguration(bucketId)
client.setBucketWebsiteConfiguration(bucketId, currentConfiguration.withRoutingRules(routingRules.asJava))
val currentConfiguration = client.getBucketWebsiteConfiguration(realBucketId)
client.setBucketWebsiteConfiguration(realBucketId, currentConfiguration.withRoutingRules(routingRules.asJava))
} catch {
case e: Throwable =>
println("failed to add redirects:")
Expand Down

0 comments on commit e6e6318

Please sign in to comment.