Browse files

Fix #365 producing huge packages because of hard links

  • Loading branch information...
1 parent ff16e2c commit 0a5b6a8ffa386cba639dbe5ac1b2404080ffa722 Vladimir Yarotsky committed Jan 22, 2014
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/fpm/util.rb
View
14 lib/fpm/util.rb
@@ -155,7 +155,19 @@ def copy_entry(src, dst)
when 'directory'
FileUtils.mkdir(dst) unless File.exists? dst
else
- FileUtils.copy_entry(src, dst)
+ # if the file with the same inode has been copied already -
+ # hard link it's copy to `dst`, otherwise make an actual copy
+ st = File.stat(src)
+ if copied_entry = copied_entries[[st.dev, st.ino]]
+ FileUtils.ln(copied_entry, dst)
+ else
+ FileUtils.copy_entry(src, dst)
+ copied_entries.store([st.dev, st.ino], dst)
+ end
end
end
+
+ def copied_entries
+ @copied_entries ||= {}
+ end
end # module FPM::Util

0 comments on commit 0a5b6a8

Please sign in to comment.