Skip to content

Fix #365 producing huge packages because of hard links #623

wants to merge 1 commit into from
+13 −1
14 lib/fpm/util.rb
@@ -155,7 +155,19 @@ def copy_entry(src, dst)
when 'directory'
FileUtils.mkdir(dst) unless File.exists? dst
- FileUtils.copy_entry(src, dst)
+ # if the file with the same dev and inode has been copied already -
+ # hard link it's copy to `dst`, otherwise make an actual copy
+ st = File.stat(src)
jordansissel added a note Mar 7, 2014

I wonder if File.lstat() is more correct here (otherwise we're following a symlink which may not be waht we want to do)

I'll fiddle with this post-merge and try to write a test for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if copied_entry = copied_entries[[, st.ino]]
+ FileUtils.ln(copied_entry, dst)
+ else
+ FileUtils.copy_entry(src, dst)
+[, st.ino], dst)
+ end
+ def copied_entries
+ @copied_entries ||= {}
+ end
end # module FPM::Util
Something went wrong with that request. Please try again.