s3_website_monadic 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86d4b06157085efd1c389f9a8ec15bdd019aa66
|
4
|
+
data.tar.gz: b4b461eb8fd319a95b87231430831ca5fc56e288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65805273617dcf99e2dedd7e32a7640fdc85fd40c055ecbe282be74bb050ab70d101cdbf5bb9c20cc703f6a1425f996c5d1a7ce972be8d203454c22682de9daf
|
7
|
+
data.tar.gz: 3f369bb8674f34540bdf5d39cff572542f93e9dced36a1aeab402213ebe1860e77f38ff058ad562a64f50fa1864718a2f90c19dd9a20a91fdf7d8108c0796ed3
|
data/s3_website.gemspec
CHANGED
@@ -104,7 +104,7 @@ object CloudFront {
|
|
104
104
|
|
105
105
|
|
106
106
|
def needsInvalidation: PartialFunction[PushSuccessReport, Boolean] = {
|
107
|
-
case SuccessfulUpload(upload) => upload.uploadType match {
|
107
|
+
case SuccessfulUpload(upload, _) => upload.uploadType match {
|
108
108
|
case Update => true
|
109
109
|
case _ => false
|
110
110
|
}
|
@@ -138,7 +138,7 @@ object Push {
|
|
138
138
|
failureOrSuccess => failureOrSuccess.fold(
|
139
139
|
(failureReport: PushFailureReport) => counts.copy(failures = counts.failures + 1),
|
140
140
|
(successReport: PushSuccessReport) => successReport match {
|
141
|
-
case SuccessfulUpload(upload) => upload.uploadType match {
|
141
|
+
case SuccessfulUpload(upload, _) => upload.uploadType match {
|
142
142
|
case NewFile => counts.copy(newFiles = counts.newFiles + 1)
|
143
143
|
case Update => counts.copy(updates = counts.updates + 1)
|
144
144
|
case Redirect => counts.copy(redirects = counts.redirects + 1)
|
@@ -21,8 +21,9 @@ class S3(implicit s3Settings: S3Settings, executor: ExecutionContextExecutor) {
|
|
21
21
|
|
22
22
|
def upload(upload: Upload with UploadTypeResolved, a: Attempt = 1)(implicit config: Config): Future[Either[FailedUpload, SuccessfulUpload]] =
|
23
23
|
Future {
|
24
|
-
|
25
|
-
|
24
|
+
val putObjectRequest = toPutObjectRequest(upload)
|
25
|
+
s3Settings.s3Client(config) putObject putObjectRequest
|
26
|
+
val report = SuccessfulUpload(upload, putObjectRequest.getMetadata)
|
26
27
|
info(report)
|
27
28
|
Right(report)
|
28
29
|
} recoverWith retry(a)(
|
@@ -136,11 +137,19 @@ object S3 {
|
|
136
137
|
def s3Key: String
|
137
138
|
}
|
138
139
|
|
139
|
-
case class SuccessfulUpload(upload: Upload with UploadTypeResolved) extends PushSuccessReport {
|
140
|
+
case class SuccessfulUpload(upload: Upload with UploadTypeResolved, metadata: ObjectMetadata) extends PushSuccessReport {
|
141
|
+
def metadataReport =
|
142
|
+
(metadata.getCacheControl :: metadata.getContentType :: metadata.getContentEncoding :: Nil)
|
143
|
+
.map(Option(_))
|
144
|
+
.collect {
|
145
|
+
case Some(metadatum) => metadatum
|
146
|
+
}
|
147
|
+
.mkString(" | ")
|
148
|
+
|
140
149
|
def reportMessage =
|
141
150
|
upload.uploadType match {
|
142
|
-
case NewFile => s"Created ${upload.s3Key}"
|
143
|
-
case Update => s"Updated ${upload.s3Key}"
|
151
|
+
case NewFile => s"Created ${upload.s3Key} ($metadataReport)"
|
152
|
+
case Update => s"Updated ${upload.s3Key} ($metadataReport)"
|
144
153
|
case Redirect => s"Redirecting ${upload.essence.left.get.key} to ${upload.essence.left.get.redirectTarget}"
|
145
154
|
}
|
146
155
|
|
@@ -85,7 +85,7 @@ class S3WebsiteSpec extends Specification {
|
|
85
85
|
}
|
86
86
|
|
87
87
|
"create a file if does not exist on S3" in new SiteDirectory with MockAWS {
|
88
|
-
implicit val site =
|
88
|
+
implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
|
89
89
|
Push.pushSite
|
90
90
|
sentPutObjectRequest.getKey must equalTo("index.html")
|
91
91
|
}
|
@@ -98,14 +98,14 @@ class S3WebsiteSpec extends Specification {
|
|
98
98
|
}
|
99
99
|
|
100
100
|
"try again if the upload fails" in new SiteDirectory with MockAWS {
|
101
|
-
implicit val site =
|
101
|
+
implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
|
102
102
|
uploadFailsAndThenSucceeds(howManyFailures = 5)
|
103
103
|
Push.pushSite
|
104
104
|
verify(amazonS3Client, times(6)).putObject(Matchers.any(classOf[PutObjectRequest]))
|
105
105
|
}
|
106
106
|
|
107
107
|
"not try again if the upload fails on because of invalid credentials" in new SiteDirectory with MockAWS {
|
108
|
-
implicit val site =
|
108
|
+
implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
|
109
109
|
when(amazonS3Client.putObject(Matchers.any(classOf[PutObjectRequest]))).thenThrow {
|
110
110
|
val e = new AmazonServiceException("your credentials are incorrect")
|
111
111
|
e.setStatusCode(403)
|