checkDiskSpace,
moveAnnex,
linkAnnex,
+ LinkAnnexResult(..),
sendAnnex,
prepSendAnnex,
removeAnnex,
- prevent losing the content if the source file is deleted, but does not
- guard against modifications.
-}
-linkAnnex :: Key -> FilePath -> Annex Bool
+linkAnnex :: Key -> FilePath -> Annex LinkAnnexResult
linkAnnex key src = do
dest <- calcRepo (gitAnnexLocation key)
ifM (liftIO $ doesFileExist dest)
- ( return True
+ ( return LinkAnnexNoop
, modifyContent dest $
- liftIO $ createLinkOrCopy src dest
+ ifM (liftIO $ createLinkOrCopy src dest)
+ ( return LinkAnnexOk
+ , return LinkAnnexFailed
+ )
)
+data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop
+
{- Runs an action to transfer an object's content.
-
- In direct mode, it's possible for the file to change as it's being sent.
import Types.KeySource
import Types.Key
import Backend
+import Logs.Location
import qualified Data.ByteString.Lazy as B
cmd :: Command
-cmd = dontCheck repoExists $
+cmd = noMessages $ dontCheck repoExists $
command "clean" SectionPlumbing
"git clean filter"
paramFile (withParams seek)
-- Hard link (or copy) file content to annex
-- to prevent it from being lost when git checks out
-- a branch not containing this file.
- unlessM (linkAnnex k file) $
- error "Problem adding file to the annex"
+ r <- linkAnnex k file
+ case r of
+ LinkAnnexFailed -> error "Problem adding file to the annex"
+ LinkAnnexOk -> logStatus k InfoPresent
+ LinkAnnexNoop -> noop
genMetaData k file
=<< liftIO (getFileStatus file)
return k