add generalized linkAnnex'

This commit is contained in:
Joey Hess 2015-12-10 16:07:50 -04:00
parent 06a8256bf6
commit 9dffd3d255
Failed to extract signature
2 changed files with 16 additions and 7 deletions

View file

@ -25,6 +25,7 @@ module Annex.Content (
checkDiskSpace, checkDiskSpace,
moveAnnex, moveAnnex,
linkAnnex, linkAnnex,
linkAnnex',
LinkAnnexResult(..), LinkAnnexResult(..),
sendAnnex, sendAnnex,
prepSendAnnex, prepSendAnnex,
@ -514,15 +515,21 @@ populatePointerFile k obj f = go =<< isPointerFile f
linkAnnex :: Key -> FilePath -> Annex LinkAnnexResult linkAnnex :: Key -> FilePath -> Annex LinkAnnexResult
linkAnnex key src = do linkAnnex key src = do
dest <- calcRepo (gitAnnexLocation key) dest <- calcRepo (gitAnnexLocation key)
modifyContent dest $ linkAnnex' key src dest
{- Hard links (or copies) src to dest, one of which should be the
- annex object. -}
linkAnnex' :: Key -> FilePath -> FilePath -> Annex LinkAnnexResult
linkAnnex' key src dest =
ifM (liftIO $ doesFileExist dest) ifM (liftIO $ doesFileExist dest)
( return LinkAnnexNoop ( return LinkAnnexNoop
, modifyContent dest $ , ifM (liftIO $ createLinkOrCopy src dest)
ifM (liftIO $ createLinkOrCopy src dest) ( do
( do thawContent dest
Database.Keys.storeInodeCaches key [dest, src] Database.Keys.storeInodeCaches key [dest, src]
return LinkAnnexOk return LinkAnnexOk
, return LinkAnnexFailed , return LinkAnnexFailed
) )
) )
data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop

View file

@ -325,6 +325,8 @@ files to be unlocked, while the indirect upgrades don't touch the files.
#### implementation todo list #### implementation todo list
* linkAnnex should check disk reserve when it falls back to copying the
file.
* Reconcile staged changes into the associated files database, whenever * Reconcile staged changes into the associated files database, whenever
the database is queried. the database is queried.
* See if the cases where the Keys database is not used can be * See if the cases where the Keys database is not used can be