class Jekyll::StaticFile
Public Instance Methods
write(dest)
click to toggle source
Redefine the write method to create hard links instead of copying the file
# File lib/jekyll/static_file.rb 7 def write(dest) 8 dest_path = destination(dest) 9 10 # If the file exists but it's not a hardlink, we remove it and 11 # replace it with one. This is useful when migrating from a site 12 # already built without this plugin. 13 if File.exist? dest_path 14 return if hardlink? dest_path, path 15 FileUtils.rm dest_path 16 end 17 18 self.class.mtimes[path] = mtime 19 20 FileUtils.mkdir_p(File.dirname(dest_path)) 21 FileUtils.ln(path, dest_path) 22 end
Private Instance Methods
hardlink?(dest_path, path)
click to toggle source
Verifies the files are the same by checking their inode
# File lib/jekyll/static_file.rb 27 def hardlink?(dest_path, path) 28 File.stat(path).ino == File.stat(dest_path).ino 29 end