s3_website 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d95afa1639efb9bbe1fc15486b146f42788a8146
4
- data.tar.gz: 4c257d8a83e28029d63b566ff03ea9a280423698
3
+ metadata.gz: b26682cbb78c10aa527d65993f265c3b97af2450
4
+ data.tar.gz: 3bd33a3a6440de3a8f83b257828bc815e0e4e439
5
5
  SHA512:
6
- metadata.gz: 80562c01d0a390e0538d65ac64686c8e01131da2b1d3a144eb5eb96459837f336652d5007889ae6783f84d8fc8aa3c6b9bfc410611a1dcfc59e4572df73cb1f6
7
- data.tar.gz: b1ed8d37b875262f75041b57d27dbb2ad2702dc8b54724b728032857b29dda84091f9ebab2deb1846a197d7cf9df8c886176df2af9b2a4415f564a1f8a795cb2
6
+ metadata.gz: c102eab9efbb9d438329a32456c5ee55a11f096fe18e25767eb7029055d76c3176c1b7bd0c085fe1df8fcf19f54708fe30c8261bec947df8a299548e27dfedde
7
+ data.tar.gz: 89fc0705033813863965ea64abec0ee1e3137f70bcf5fdfe3bda40380aeb062cd5d9a6c79a3d535ae1cd4ce4ba579388abc595239a1bdec83cf2c923c8259f8c
data/README.md CHANGED
@@ -169,6 +169,9 @@ ignore_on_server:
169
169
  - file_managed_by_somebody_else
170
170
  ```
171
171
 
172
+ If you add the magic word `ignore_on_server: _DELETE_NOTHING_ON_THE_S3_BUCKET_`,
173
+ `s3_website push` will never delete any objects on the bucket.
174
+
172
175
  ### Excluding files from upload
173
176
 
174
177
  You can instruct `s3_website` not to push certain files:
data/changelog.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 2.4.0
6
+
7
+ * Add `ignore_on_server: _DELETE_NOTHING_ON_THE_S3_BUCKET_` for the sake of convenience
8
+
9
+ See https://github.com/laurilehmijoki/s3_website/issues/121 for discussion.
10
+
5
11
  ## 2.3.1
6
12
 
7
13
  * Add Windows support
@@ -1,3 +1,3 @@
1
1
  module S3Website
2
- VERSION = '2.3.1'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -1 +1 @@
1
- 15aaf120b5c2233ae3302f570baccd4a
1
+ d4b00c407f92dde48e4937d61c7be20d
@@ -39,23 +39,29 @@ object Diff {
39
39
  }
40
40
 
41
41
  def resolveDeletes(s3Files: Future[Either[ErrorReport, Seq[S3File]]], redirects: Seq[Redirect])
42
- (implicit site: Site, logger: Logger, executor: ExecutionContextExecutor): Future[Either[ErrorReport, Seq[S3Key]]] = {
43
- val localS3Keys = Files.listSiteFiles.map(site resolveS3Key)
44
-
45
- s3Files map { s3Files: Either[ErrorReport, Seq[S3File]] =>
46
- for {
47
- remoteS3Keys <- s3Files.right.map(_ map (_.s3Key)).right
48
- } yield {
49
- val keysToRetain = (localS3Keys ++ (redirects map { _.s3Key })).toSet
50
- remoteS3Keys filterNot { s3Key =>
51
- val ignoreOnServer = site.config.ignore_on_server.exists(_.fold(
52
- (ignoreRegex: String) => rubyRegexMatches(s3Key, ignoreRegex),
53
- (ignoreRegexes: Seq[String]) => ignoreRegexes.exists(rubyRegexMatches(s3Key, _))
54
- ))
55
- if (ignoreOnServer) logger.debug(s"Ignoring $s3Key on server")
56
- (keysToRetain contains s3Key) || ignoreOnServer
42
+ (implicit site: Site, logger: Logger, executor: ExecutionContextExecutor): Future[Either[ErrorReport, Seq[S3Key]]] =
43
+ if (site.config.ignore_on_server.contains(Left(DELETE_NOTHING_MAGIC_WORD))) {
44
+ logger.debug(s"Ignoring all files on the bucket, since the setting $DELETE_NOTHING_MAGIC_WORD is on.")
45
+ Future(Right(Nil))
46
+ } else {
47
+ val localS3Keys = Files.listSiteFiles.map(site resolveS3Key)
48
+
49
+ s3Files map { s3Files: Either[ErrorReport, Seq[S3File]] =>
50
+ for {
51
+ remoteS3Keys <- s3Files.right.map(_ map (_.s3Key)).right
52
+ } yield {
53
+ val keysToRetain = (localS3Keys ++ (redirects map { _.s3Key })).toSet
54
+ remoteS3Keys filterNot { s3Key =>
55
+ val ignoreOnServer = site.config.ignore_on_server.exists(_.fold(
56
+ (ignoreRegex: String) => rubyRegexMatches(s3Key, ignoreRegex),
57
+ (ignoreRegexes: Seq[String]) => ignoreRegexes.exists(rubyRegexMatches(s3Key, _))
58
+ ))
59
+ if (ignoreOnServer) logger.debug(s"Ignoring $s3Key on server")
60
+ (keysToRetain contains s3Key) || ignoreOnServer
61
+ }
57
62
  }
58
63
  }
59
64
  }
60
- }
65
+
66
+ val DELETE_NOTHING_MAGIC_WORD = "_DELETE_NOTHING_ON_THE_S3_BUCKET_"
61
67
  }
@@ -18,6 +18,7 @@ import org.mockito.{ArgumentCaptor, Matchers, Mockito}
18
18
  import org.specs2.mutable.{BeforeAfter, Specification}
19
19
  import org.specs2.specification.Scope
20
20
  import s3.website.CloudFront.CloudFrontSetting
21
+ import s3.website.Diff.DELETE_NOTHING_MAGIC_WORD
21
22
  import s3.website.Push.{CliArgs}
22
23
  import s3.website.S3.S3Setting
23
24
  import s3.website.model.Config.S3_website_yml
@@ -344,6 +345,17 @@ class S3WebsiteSpec extends Specification {
344
345
  }
345
346
  }
346
347
 
348
+ "ignore_on_server: _DELETE_NOTHING_ON_THE_S3_BUCKET_" should {
349
+ "result in no files being deleted on the S3 bucket" in new BasicSetup {
350
+ config = s"""
351
+ |ignore_on_server: $DELETE_NOTHING_MAGIC_WORD
352
+ """.stripMargin
353
+ setS3Files(S3File("file.txt", ""))
354
+ push
355
+ noDeletesOccurred
356
+ }
357
+ }
358
+
347
359
  """
348
360
  ignore_on_server:
349
361
  - regex
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
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-08-18 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor