From 5b2f16f02f8cd177e9d405b2ac62476ef2c86faa Mon Sep 17 00:00:00 2001 From: f <f@sutty.nl> Date: Wed, 30 Dec 2020 14:26:03 -0300 Subject: [PATCH] v0.1.2 -- actually check if the files are the same and ruby 3 support --- jekyll-hardlinks.gemspec | 5 ++--- lib/jekyll/static_file.rb | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/jekyll-hardlinks.gemspec b/jekyll-hardlinks.gemspec index ec71047..547dae4 100644 --- a/jekyll-hardlinks.gemspec +++ b/jekyll-hardlinks.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'jekyll-hardlinks' - spec.version = '0.1.1' + spec.version = '0.1.2' spec.authors = %w[f] spec.email = %w[f@sutty.nl] @@ -8,7 +8,6 @@ Gem::Specification.new do |spec| spec.description = 'Jekyll copies static files and duplicates storage use. Hard links point to the same file instead of making copies, thus saving storage.' spec.homepage = "https://0xacab.org/sutty/jekyll/#{spec.name}" spec.license = 'GPL-3.0' - spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0') spec.metadata = { 'bug_tracker_uri' => "#{spec.homepage}/issues", @@ -30,7 +29,7 @@ Gem::Specification.new do |spec| '--quiet' ] - spec.required_ruby_version = '~> 2' + spec.required_ruby_version = '>= 2.6' spec.add_dependency 'jekyll', '~> 4' end diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index d60d56c..b4d32a6 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -11,7 +11,7 @@ module Jekyll # replace it with one. This is useful when migrating from a site # already built without this plugin. if File.exist? dest_path - return if hardlink? dest_path + return if hardlink? dest_path, path FileUtils.rm dest_path end @@ -23,9 +23,9 @@ module Jekyll private - # Verifies the path has hardlinks - def hardlink?(path) - File.stat(path).nlink > 1 + # Verifies the files are the same by checking their inode + def hardlink?(dest_path, path) + File.stat(path).ino == File.stat(dest_path).ino end end end -- GitLab