Supports indirect mode on encfs in paranoia mode, and other filesystems that do not support hard links, but do support symlinks and other POSIX filesystem features.
This commit is contained in:
parent
9cf6d8130c
commit
a64106dcef
6 changed files with 65 additions and 45 deletions
|
@ -1,11 +1,16 @@
|
|||
{- git-annex file copying
|
||||
{- file copying
|
||||
-
|
||||
- Copyright 2010,2012 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Utility.CopyFile (copyFileExternal) where
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Utility.CopyFile (
|
||||
copyFileExternal,
|
||||
createLinkOrCopy
|
||||
) where
|
||||
|
||||
import Common
|
||||
import qualified Build.SysConfig as SysConfig
|
||||
|
@ -23,3 +28,17 @@ copyFileExternal src dest = do
|
|||
, (SysConfig.cp_a, Param "-a")
|
||||
, (SysConfig.cp_p && not SysConfig.cp_a, Param "-p")
|
||||
]
|
||||
|
||||
{- Create a hard link if the filesystem allows it, and fall back to copying
|
||||
- the file. -}
|
||||
createLinkOrCopy :: FilePath -> FilePath -> IO Bool
|
||||
#ifndef __WINDOWS__
|
||||
createLinkOrCopy src dest = go `catchIO` const fallback
|
||||
where
|
||||
go = do
|
||||
createLink src dest
|
||||
return True
|
||||
fallback = copyFileExternal src dest
|
||||
#else
|
||||
createLinkOrCopy = copyFileExternal
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue