s3_website_monadic 0.0.34 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/s3_website/version.rb +1 -1
- data/src/main/scala/s3/website/Diff.scala +10 -5
- data/src/test/scala/s3/website/S3WebsiteSpec.scala +20 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a588d29f02ef097314aa16ec55674fa6eccbe09
|
4
|
+
data.tar.gz: caf04222e53fdd2cacdadcc6897f9d59cfd7b850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d6891706690b50a98966cd6860e0680ccd9e478f5a1ec2fc0c0c92a0af6e42777c546486d826177b85c73a3911eeabce9ec4b1a32f2b8a645778f99d7ad771
|
7
|
+
data.tar.gz: 0d49bbcd125387e1d9fcbd8346e784ff4f4957e30ecc0839fcb2714680a68c3a4bc9f7ddfacfc63238fd542d7dc013d63af61ed4a2d09d8d2cdb25cf17c273d3
|
data/lib/s3_website/version.rb
CHANGED
@@ -151,15 +151,20 @@ object Diff {
|
|
151
151
|
|
152
152
|
val changesMissedByLocalDiff: Future[Either[ErrorReport, Seq[LocalFileFromDisk]]] = s3FilesFuture.map { errorOrS3Files =>
|
153
153
|
for (s3Files <- errorOrS3Files.right) yield {
|
154
|
+
val remoteS3Keys = s3Files.map(_.s3Key).toSet
|
154
155
|
val localS3Keys = unchangedAccordingToLocalDiff.map(_.s3Key).toSet
|
155
156
|
val localMd5 = unchangedAccordingToLocalDiff.map(_.uploadFileMd5).toSet
|
156
|
-
|
157
|
-
|
157
|
+
def isChangedOnS3(s3File: S3File) = (localS3Keys contains s3File.s3Key) && !(localMd5 contains s3File.md5)
|
158
|
+
val changedOnS3 = s3Files collect {
|
159
|
+
case s3File if isChangedOnS3(s3File) =>
|
160
|
+
LocalFileFromDisk(site resolveFile s3File, FileUpdate)
|
158
161
|
}
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
+
val missingFromS3 = localS3Keys collect {
|
163
|
+
case localS3Key if !(remoteS3Keys contains localS3Key) =>
|
164
|
+
LocalFileFromDisk(site resolveFile localS3Key, NewFile)
|
165
|
+
|
162
166
|
}
|
167
|
+
changedOnS3 ++ missingFromS3
|
163
168
|
}
|
164
169
|
}
|
165
170
|
|
@@ -27,6 +27,7 @@ import s3.website.Push.{push, CliArgs}
|
|
27
27
|
import s3.website.CloudFront.CloudFrontSetting
|
28
28
|
import s3.website.S3.S3Setting
|
29
29
|
import org.apache.commons.codec.digest.DigestUtils
|
30
|
+
import java.util.Date
|
30
31
|
|
31
32
|
class S3WebsiteSpec extends Specification {
|
32
33
|
|
@@ -588,6 +589,15 @@ class S3WebsiteSpec extends Specification {
|
|
588
589
|
push
|
589
590
|
sentPutObjectRequests.length must equalTo(2)
|
590
591
|
}
|
592
|
+
|
593
|
+
"push locally unchanged files that are missing from S3" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
|
594
|
+
setLocalFileWithContentAndLastModified(("file.txt", "contents", new Date(1400000000000L)))
|
595
|
+
push
|
596
|
+
// Simulate the situation where someone else has deleted file.txt, and we push for the second time
|
597
|
+
setLocalFileWithContentAndLastModified(("file.txt", "contents", new Date(1400000000000L)))
|
598
|
+
push
|
599
|
+
sentPutObjectRequests.length must equalTo(2) // Even though we use the local db, we should notice that someone else has deleted file.txt
|
600
|
+
}
|
591
601
|
}
|
592
602
|
|
593
603
|
"Jekyll site" should {
|
@@ -785,11 +795,15 @@ class S3WebsiteSpec extends Specification {
|
|
785
795
|
|
786
796
|
trait EmptySite extends Directories {
|
787
797
|
type LocalFileWithContent = (String, String)
|
798
|
+
type LocalFileWithContentAndLastModified = (String, String, Date)
|
788
799
|
|
789
|
-
val localFilesWithContent: mutable.Set[
|
800
|
+
val localFilesWithContent: mutable.Set[LocalFileWithContentAndLastModified] = mutable.Set()
|
790
801
|
def setLocalFile(fileName: String) = setLocalFileWithContent((fileName, ""))
|
791
802
|
def setLocalFiles(fileNames: String*) = fileNames foreach setLocalFile
|
792
|
-
def setLocalFileWithContent(fileNameAndContent: LocalFileWithContent) =
|
803
|
+
def setLocalFileWithContent(fileNameAndContent: LocalFileWithContent) =
|
804
|
+
setLocalFileWithContentAndLastModified((fileNameAndContent._1, fileNameAndContent._2, new Date))
|
805
|
+
def setLocalFileWithContentAndLastModified(fileNameAndContentAndLastModified: LocalFileWithContentAndLastModified) =
|
806
|
+
localFilesWithContent += fileNameAndContentAndLastModified
|
793
807
|
def setLocalFilesWithContent(fileNamesAndContent: LocalFileWithContent*) = fileNamesAndContent foreach setLocalFileWithContent
|
794
808
|
var config = ""
|
795
809
|
val baseConfig =
|
@@ -802,15 +816,16 @@ class S3WebsiteSpec extends Specification {
|
|
802
816
|
implicit def cliArgs: CliArgs = siteWithFilesAndContent(config, localFilesWithContent)
|
803
817
|
def pushMode: PushMode // Represents the --dry-run switch
|
804
818
|
|
805
|
-
private def siteWithFilesAndContent(config: String = "", localFilesWithContent: mutable.Set[
|
819
|
+
private def siteWithFilesAndContent(config: String = "", localFilesWithContent: mutable.Set[LocalFileWithContentAndLastModified]): CliArgs = {
|
806
820
|
localFilesWithContent.foreach {
|
807
|
-
case (filePath, content) =>
|
821
|
+
case (filePath, content, lastModified) =>
|
808
822
|
val file = new File(siteDirectory, filePath)
|
809
823
|
forceMkdir(file.getParentFile)
|
810
824
|
file.createNewFile()
|
811
825
|
write(file, content)
|
812
|
-
|
826
|
+
file.setLastModified(lastModified.getTime)
|
813
827
|
}
|
828
|
+
localFilesWithContent.clear() // Once we've persisted the changes on the disk, clear the queue. I.e., keep the state where it should be – on the disk.
|
814
829
|
buildCliArgs(config)
|
815
830
|
}
|
816
831
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_website_monadic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|