From fd5f2eb39932f313e5264f6c79b1c073aa7162d4 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 28 Sep 2016 16:54:58 -0700 Subject: [PATCH 1/2] Add failing test for File.utime of a symlink in staticfile. --- test/test_static_file.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_static_file.rb b/test/test_static_file.rb index 285ec879ffe..71b3f31cd58 100644 --- a/test/test_static_file.rb +++ b/test/test_static_file.rb @@ -112,6 +112,14 @@ def setup_static_file_with_defaults(base, dir, name, defaults) assert_equal Time.new.to_i, @static_file.mtime end + should "only set modified time if not a symlink" do + expect(File).to receive(:symlink?).and_return(true) + expect(File).not_to receive(:utime) + @static_file.write(dest_dir) + + allow(File).to receive(:symlink?).and_call_original + end + should "known if the source path is modified, when it is" do sleep 1 modify_dummy_file(@filename) From 8e912630310f913d7fd7397dbd640853f2ebc7bb Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 28 Sep 2016 16:55:57 -0700 Subject: [PATCH 2/2] StaticFile#copy_entry: don't mark modified time if path is a symlink --- lib/jekyll/static_file.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 0f8544ee7da..e11d6689720 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -146,7 +146,10 @@ def copy_file(dest_path) else FileUtils.copy_entry(path, dest_path) end - File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path) + + unless File.symlink?(dest_path) + File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path) + end end end end