From 4686c99c02cffc2ef52774f74dc3bd4ec5fb2fcd Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 5 Dec 2019 21:59:13 +0530 Subject: [PATCH 1/4] Add an option to easily disable disk-cache --- lib/jekyll/command.rb | 2 ++ lib/jekyll/site.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index 68bc8cbe250..bd589cc5018 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -67,6 +67,8 @@ def add_build_options(cmd) cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" cmd.option "unpublished", "--unpublished", "Render posts that were marked as unpublished" + cmd.option "disable_disk_cache", "--no-disk-cache", + "Disable caching to disk in non-safe mode" cmd.option "quiet", "-q", "--quiet", "Silence output." cmd.option "verbose", "-V", "--verbose", "Print verbose output." cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild." diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 8aca2d655a0..281c2fe592c 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -470,7 +470,7 @@ def site_cleaner # Disable Marshaling cache to disk in Safe Mode def configure_cache Jekyll::Cache.cache_dir = in_source_dir(config["cache_dir"], "Jekyll/Cache") - Jekyll::Cache.disable_disk_cache! if safe + Jekyll::Cache.disable_disk_cache! if safe || config["disable_disk_cache"] end def configure_plugins From 57f08b4d28cf140922216a33ada081f8c7dba020 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 9 Dec 2019 15:51:38 +0530 Subject: [PATCH 2/4] Rename CLI option to `--disable-disk-cache` Mercenary interprets `--no-*` as a falsy. But we need `disable_disk_cache` to have a truthy value instead. --- lib/jekyll/command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index bd589cc5018..be8890e72de 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -67,7 +67,7 @@ def add_build_options(cmd) cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" cmd.option "unpublished", "--unpublished", "Render posts that were marked as unpublished" - cmd.option "disable_disk_cache", "--no-disk-cache", + cmd.option "disable_disk_cache", "--disable-disk-cache", "Disable caching to disk in non-safe mode" cmd.option "quiet", "-q", "--quiet", "Silence output." cmd.option "verbose", "-V", "--verbose", "Print verbose output." From 923ffcc1788bb3a09e5a744dc6a38d7b0402884a Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 9 Dec 2019 15:53:38 +0530 Subject: [PATCH 3/4] Test this feature via Cucumber --- features/cache.feature | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/features/cache.feature b/features/cache.feature index f6f62af11dd..156b35ca453 100644 --- a/features/cache.feature +++ b/features/cache.feature @@ -35,3 +35,12 @@ Feature: Cache But the .jekyll-cache directory should not exist And the _site directory should exist And I should see "

Hello World

" in "_site/index.html" + + Scenario: Disabling disk usage in non-safe mode + Given I have an "index.md" page that contains "{{ site.title }}" + And I have a configuration file with "title" set to "Hello World" + When I run jekyll build --disable-disk-cache + Then I should get a zero exit status + And the _site directory should exist + And I should see "

Hello World

" in "_site/index.html" + But the .jekyll-cache directory should not exist From 4012fe607129604baff249090816515fe230f165 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 9 Dec 2019 16:33:21 +0530 Subject: [PATCH 4/4] Add documentation for `--disable-disk-cache` --- docs/_docs/configuration/options.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/_docs/configuration/options.md b/docs/_docs/configuration/options.md index 6bd23f6b3d3..40a507ade14 100644 --- a/docs/_docs/configuration/options.md +++ b/docs/_docs/configuration/options.md @@ -43,13 +43,35 @@ class="flag">flags (specified on the command-line) that control them.

Safe

-

Disable custom plugins, and ignore symbolic links.

+

+ Disable custom plugins, caching to disk + and ignore symbolic links. +

safe: BOOL

--safe

+ + +

+ Disable Disk Cache + 4.1.0 +

+

+ Disable caching of content to disk in order to skip creating a + .jekyll-cache or similar directory at the source + to avoid interference with virtual environments and third-party + directory watchers. + Caching to disk is always disabled in safe mode. +

+ + +

disable_disk_cache: BOOL

+

--disable-disk-cache

+ +

Exclude