From 823c510414ca5ca583c21d984f527e8be0742fa4 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Tue, 15 May 2012 00:05:56 -0700 Subject: [PATCH] - only set permissions/ownership/times if the source and destinations aren't pointing at the same inode. --- lib/fpm/package/dir.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/fpm/package/dir.rb b/lib/fpm/package/dir.rb index 47538a856e..b66e4e12cf 100644 --- a/lib/fpm/package/dir.rb +++ b/lib/fpm/package/dir.rb @@ -112,15 +112,20 @@ def copy(source, destination) end # def copy def copy_metadata(source, destination) - st = File::lstat(source) - File.utime(st.atime, st.mtime, destination) + source_stat = File::lstat(source) + dest_stat = File::lstat(destination) + + # If this is a hard-link, there's no metadata to copy. + return if source_stat.ino == dest_stat.ino + + File.utime(source_stat.atime, source_stat.mtime, destination) begin - File.chown(st.uid, st.gid, destination) + File.chown(source_stat.uid, source_stat.gid, destination) rescue Errno::EPERM # clear setuid/setgid - File.chmod(st.mode & 01777, destination) + File.chmod(source_stat.mode & 01777, destination) else - File.chmod(st.mode, destination) + File.chmod(source_stat.mode, destination) end end # def copy_metadata