laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.24k stars 187 forks source link

All files containing the string "env" are excluded #204

Closed shortjared closed 8 years ago

shortjared commented 8 years ago

This caused me a couple hours of debugging trying to track down why only one specific file generated with Jekyll would not deploy no matter what I did.

It turns out that any file that contains the substring "env" in the file name gets excluded by s3_website. So for instance 2015-12-15-talking-about-your-environments/index.html, gets excluded (silent by default).

def listSiteFiles(implicit site: Site, logger: Logger) = {
def excludeFromUpload(s3Key: S3Key) = {
val excludeByConfig = site.config.exclude_from_upload exists {
        _.s3KeyRegexes.exists(_ matches s3Key)
      }
val neverUpload = "s3_website.yml" :: ".env" :: Nil map (k => S3Key.build(k, site.config.s3_key_prefix))
val doNotUpload = excludeByConfig || (neverUpload contains s3Key)
if (doNotUpload) logger.debug(s"Excluded $s3Key from upload")
      doNotUpload
    }
    recursiveListFiles(site.rootDirectory)
      .filterNot(_.isDirectory)
      .filterNot(f => excludeFromUpload(site.resolveS3Key(f)))
  }
}

I believe the guilty line is: https://github.com/laurilehmijoki/s3_website/blob/a17868b3bdd498d0331c48078dc9b67455e9264a/src/main/scala/s3/website/model/push.scala#L135

laurilehmijoki commented 8 years ago

Hi @shortjared, I'm unable to reproduce this bug. Here's what I do:

$ cd my-jekyll-site
$ cd _site/
$ mkdir 2015-12-15-talking-about-your-environments
$ touch index.html
$ cd ..
$ cd ..
$ s3_website push
[info] Deploying /tmp/_site/* to my-test-site.com
[succ] Created 2015-12-15-talking-about-your-environments/index.html (public, max-age=120 | text/html; charset=utf-8 | gzip)
[info] Summary: Created 1 file. Applied 1 redirect. Transferred 20 B, 0 B/s.
[info] Successfully pushed the website to http://my-test-site.s3-website-us-east-1.amazonaws.com

It seems to me that the code at https://github.com/laurilehmijoki/s3_website/blob/a17868b3bdd498d0331c48078dc9b67455e9264a/src/main/scala/s3/website/model/push.scala#L135 does not imply that it matches all the files that contain the string env. The Scala REPL also seems to agree:

scala> Seq(".env") contains "2015-12-15-talking-about-your-environments/index.html"
res0: Boolean = false

Is there something in your exclude_from_upload setting? Values in that setting are treated as regular expressions.

shortjared commented 8 years ago

Interesting. Yep.

exclude_from_upload:
  - .env

.env is treated as the regex so anything with env gets kicked out. Closing, thanks!