content locking during drop working for local git remotes

Only ssh remotes lack locking now
This commit is contained in:
Joey Hess 2015-10-09 13:07:03 -04:00
parent ceb5819538
commit 4c6095b6f5
Failed to extract signature
4 changed files with 52 additions and 8 deletions

View file

@ -53,6 +53,7 @@ import Annex.Path
import Creds
import Annex.CatFile
import Messages.Progress
import Types.NumCopies
import Control.Concurrent
import Control.Concurrent.MSampleVar
@ -142,7 +143,7 @@ gen r u c gc
, retrieveKeyFile = copyFromRemote new
, retrieveKeyFileCheap = copyFromRemoteCheap new
, removeKey = dropKey new
, lockContent = Nothing
, lockContent = Just (lockKey new)
, checkPresent = inAnnex new
, checkPresentCheap = repoCheap r
, whereisKey = Nothing
@ -359,6 +360,16 @@ dropKey r key
| Git.repoIsHttp (repo r) = error "dropping from http remote not supported"
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
lockKey :: Remote -> Key -> (VerifiedCopy -> Annex r) -> Annex r
lockKey r key a
| not $ Git.repoIsUrl (repo r) =
guardUsable (repo r) cantlock $
onLocal r $ Annex.Content.lockContentShared key a
| Git.repoIsHttp (repo r) = cantlock
| otherwise = error "TODO"
where
cantlock = error "can't lock content"
{- Tries to copy a key's content from a remote's annex to a file. -}
copyFromRemote :: Remote -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex (Bool, Verification)
copyFromRemote r key file dest p = parallelMetered (Just p) key file $