Class: Jekyll::StaticFile
- Inherits:
-
Object
- Object
- Jekyll::StaticFile
- Defined in:
- lib/jekyll/static_file.rb
Instance Method Summary collapse
-
#write(dest) ⇒ Object
Redefine the write method to create hard links instead of copying the file.
Instance Method Details
#write(dest) ⇒ Object
Redefine the write method to create hard links instead of copying the file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll/static_file.rb', line 7 def write(dest) dest_path = destination(dest) # If the file exists but it's not a hardlink, we remove it and # 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, path FileUtils.rm dest_path end self.class.mtimes[path] = mtime FileUtils.mkdir_p(File.dirname(dest_path)) begin FileUtils.ln(path, dest_path) rescue Errno::EXDEV Jekyll.logger.warn 'Jekyll::StaticFile', "Cross-device link found, copying to #{dest_path} instead" copy_file(dest_path) end end |