s3_website_monadic 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/s3_website.gemspec +1 -1
- data/src/main/scala/s3/website/CloudFront.scala +10 -1
- data/src/test/scala/s3/website/S3WebsiteSpec.scala +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64e9b6093bd40e0e6728a66dcfcf5134e5b72d52
|
4
|
+
data.tar.gz: 6aa1819b0581575150f767fc253f63a635c53a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dcb71a7dd601dca1d6d85f387f97170f7c09eb9e185db2755334af4137f99e42877fffca2ec46ca8995efbaa17ab78fd32dbae866cb91dfbf7b8122263f2f68
|
7
|
+
data.tar.gz: 3fc944d61d92e04cf7d20532a091a3492c9d22e237c41a659087cb3c8175ff2c023ca8d4fbf59fcf92636007c93fa2b08241f68f21589ab670d7669204004dca
|
data/s3_website.gemspec
CHANGED
@@ -15,6 +15,8 @@ import scala.util.Failure
|
|
15
15
|
import s3.website.CloudFront.SuccessfulInvalidation
|
16
16
|
import scala.util.Success
|
17
17
|
import s3.website.CloudFront.FailedInvalidation
|
18
|
+
import java.net.{URI, URLEncoder}
|
19
|
+
import java.net.URLEncoder.encode
|
18
20
|
|
19
21
|
class CloudFront(implicit cfClient: CloudFrontClientProvider, sleepUnit: TimeUnit) {
|
20
22
|
|
@@ -82,7 +84,14 @@ object CloudFront {
|
|
82
84
|
def toInvalidationBatches(pushSuccessReports: Seq[PushSuccessReport])(implicit config: Config): Seq[InvalidationBatch] =
|
83
85
|
pushSuccessReports
|
84
86
|
.filterNot(isRedirect) // Assume that redirect objects are never cached.
|
85
|
-
.map(
|
87
|
+
.map(report =>
|
88
|
+
new URI(
|
89
|
+
"http",
|
90
|
+
"cloudfront", // We want to use the encoder in the URI class. These must be passed in.
|
91
|
+
"/" + report.s3Key, // CloudFront keys have the slash in front
|
92
|
+
null
|
93
|
+
).toURL.getPath // The URL class encodes the unsafe characters
|
94
|
+
)
|
86
95
|
.map { path =>
|
87
96
|
if (config.cloudfront_invalidate_root.exists(_ == true))
|
88
97
|
path.replaceFirst("/index.html$", "/")
|
@@ -93,7 +93,9 @@ class S3WebsiteSpec extends Specification {
|
|
93
93
|
Push.pushSite
|
94
94
|
sentDelete must equalTo("old.html")
|
95
95
|
}
|
96
|
-
|
96
|
+
}
|
97
|
+
|
98
|
+
"push with CloudFront" should {
|
97
99
|
"invalidate the CloudFront items" in new SiteDirectory with MockAWS {
|
98
100
|
implicit val site = siteWithFiles(
|
99
101
|
config = defaultConfig.copy(cloudfront_distribution_id = Some("EGM1J2JJX9Z")),
|
@@ -120,6 +122,15 @@ class S3WebsiteSpec extends Specification {
|
|
120
122
|
Push.pushSite must equalTo(0) // The retries should finally result in a success
|
121
123
|
sentInvalidationRequests.length must equalTo(4)
|
122
124
|
}
|
125
|
+
|
126
|
+
"encode unsafe characters in the keys" in new SiteDirectory with MockAWS {
|
127
|
+
implicit val site = siteWithFiles(
|
128
|
+
config = defaultConfig.copy(cloudfront_distribution_id = Some("EGM1J2JJX9Z")),
|
129
|
+
localFiles = "articles/arnold's file.html" :: Nil
|
130
|
+
)
|
131
|
+
Push.pushSite
|
132
|
+
sentInvalidationRequest.getInvalidationBatch.getPaths.getItems.toSeq.sorted must equalTo(("/articles/arnold's%20file.html" :: Nil).sorted)
|
133
|
+
}
|
123
134
|
}
|
124
135
|
|
125
136
|
"cloudfront_invalidate_root: true" should {
|