diff --git a/changelog.md b/changelog.md index 9ff5bf3f..b8169f66 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,11 @@ This project uses [Semantic Versioning](http://semver.org). +## 2.11.2 + +* A new fix based on + + ## 2.11.1 * Prevent runaway recursion in file listing diff --git a/lib/s3_website/version.rb b/lib/s3_website/version.rb index 6e6d4118..d9e190d7 100644 --- a/lib/s3_website/version.rb +++ b/lib/s3_website/version.rb @@ -1,3 +1,3 @@ module S3Website - VERSION = '2.11.1' + VERSION = '2.11.2' end diff --git a/src/main/scala/s3/website/model/Site.scala b/src/main/scala/s3/website/model/Site.scala index ad6cba50..598e10c6 100644 --- a/src/main/scala/s3/website/model/Site.scala +++ b/src/main/scala/s3/website/model/Site.scala @@ -101,7 +101,7 @@ object Site { | site: dist/website""".stripMargin def resolveSiteDir(implicit yamlConfig: S3_website_yml, config: Config, cliArgs: CliArgs, workingDirectory: File): Either[ErrorReport, File] = { - val siteFromAutoDetect = autodetectSiteDir(workingDirectory) + val siteFromAutoDetect = if (config.site.isEmpty) { autodetectSiteDir(workingDirectory) } else { None } val errOrSiteFromCliArgs: Either[ErrorReport, Option[File]] = Option(cliArgs.site) match { case Some(siteDirFromCliArgs) => val f = new File(siteDirFromCliArgs) diff --git a/src/main/scala/s3/website/model/push.scala b/src/main/scala/s3/website/model/push.scala index 2f0a8271..0d967533 100644 --- a/src/main/scala/s3/website/model/push.scala +++ b/src/main/scala/s3/website/model/push.scala @@ -119,10 +119,10 @@ object Upload { } object Files { - def recursiveListFiles(maxDepth: Int = Integer.MAX_VALUE)(f: File): Seq[File] = { + def recursiveListFiles(f: File): Seq[File] = { val these = f.listFiles if (these != null) - these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles(maxDepth - 1)) + these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles) else Nil } @@ -137,7 +137,7 @@ object Files { if (doNotUpload) logger.debug(s"Excluded $s3Key from upload") doNotUpload } - recursiveListFiles()(site.rootDirectory) + recursiveListFiles(site.rootDirectory) .filterNot(_.isDirectory) .filterNot(f => excludeFromUpload(site.resolveS3Key(f))) } diff --git a/src/main/scala/s3/website/model/ssg.scala b/src/main/scala/s3/website/model/ssg.scala index f8d6a847..d46ea268 100644 --- a/src/main/scala/s3/website/model/ssg.scala +++ b/src/main/scala/s3/website/model/ssg.scala @@ -11,10 +11,8 @@ trait Ssg { object Ssg { val automaticallySupportedSiteGenerators = Jekyll :: Nanoc :: Nil - val maxAutodetectDepth = automaticallySupportedSiteGenerators.map(_.outputDirectory).map(_.split(File.separatorChar).length).max - def autodetectSiteDir(workingDirectory: File): Option[File] = - recursiveListFiles(maxAutodetectDepth)(workingDirectory).find { file => + recursiveListFiles(workingDirectory).find { file => file.isDirectory && automaticallySupportedSiteGenerators.exists(ssg => file.getAbsolutePath.endsWith(ssg.outputDirectory)) } }