summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-05-15 14:18:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-05-15 14:18:51 -0400
commite36808e167815eaa70a827ea703ed98ebb36da64 (patch)
treeed808617e1b8ace4eebbdc26e380a1c8b81d184c /Utility
parent300d3cbdef2450b21c9eb22361161af37ca2f266 (diff)
Pass -a to cp even when it supports --reflink=auto, to preserve permissions.
Amoung other things, this makes unlocking a WORM backed file and then re-adding it without making any changes not add a new object, as the timestamp is preserved.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/CopyFile.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Utility/CopyFile.hs b/Utility/CopyFile.hs
index 01639ef2a..66b88e4f0 100644
--- a/Utility/CopyFile.hs
+++ b/Utility/CopyFile.hs
@@ -1,6 +1,6 @@
{- git-annex file copying
-
- - Copyright 2010 Joey Hess <joey@kitenet.net>
+ - Copyright 2010,2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -16,10 +16,10 @@ copyFileExternal :: FilePath -> FilePath -> IO Bool
copyFileExternal src dest = do
whenM (doesFileExist dest) $
removeFile dest
- boolSystem "cp" [params, File src, File dest]
+ boolSystem "cp" $ params ++ [File src, File dest]
where
- params
- | SysConfig.cp_reflink_auto = Params "--reflink=auto"
- | SysConfig.cp_a = Params "-a"
- | SysConfig.cp_p = Params "-p"
- | otherwise = Params ""
+ params = map snd $ filter fst
+ [ (SysConfig.cp_reflink_auto, Param "--reflink=auto")
+ , (SysConfig.cp_a, Param "-a")
+ , (SysConfig.cp_p && not SysConfig.cp_a, Param "-p")
+ ]