Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #365 producing huge packages because of hard links

  • Loading branch information...
commit 32c6be5488ed5a193498528c23620cb1c5aa5d31 1 parent d18986f
v-yarotsky v-yarotsky authored committed
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/fpm/util.rb
14 lib/fpm/util.rb
View
@@ -166,7 +166,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 dev and 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
Please sign in to comment.
Something went wrong with that request. Please try again.