safer inannex checking
git-annex-shell inannex now returns always 0, 1, or 100 (the last when it's unclear if content is currently in the index due to it currently being moved or dropped). (Actual locking code still not yet written.)
This commit is contained in:
parent
2934a65ac5
commit
d3e1a3619f
14 changed files with 93 additions and 50 deletions
|
@ -52,7 +52,7 @@ startRemote file numcopies key remote = do
|
|||
next $ performRemote key numcopies remote
|
||||
|
||||
performLocal :: Key -> Maybe Int -> CommandPerform
|
||||
performLocal key numcopies = lockExclusive key $ do
|
||||
performLocal key numcopies = lockContent key $ do
|
||||
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
|
||||
untrusteduuids <- trustGet UnTrusted
|
||||
let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids++untrusteduuids)
|
||||
|
@ -64,7 +64,7 @@ performLocal key numcopies = lockExclusive key $ do
|
|||
else stop
|
||||
|
||||
performRemote :: Key -> Maybe Int -> Remote.Remote Annex -> CommandPerform
|
||||
performRemote key numcopies remote = lockExclusive key $ do
|
||||
performRemote key numcopies remote = lockContent key $ do
|
||||
-- Filter the remote it's being dropped from out of the lists of
|
||||
-- places assumed to have the key, and places to check.
|
||||
-- When the local repo has the key, that's one additional copy.
|
||||
|
@ -95,7 +95,7 @@ cleanupRemote key remote ok = do
|
|||
-- better safe than sorry: assume the remote dropped the key
|
||||
-- even if it seemed to fail; the failure could have occurred
|
||||
-- after it really dropped it
|
||||
Remote.remoteHasKey remote key False
|
||||
Remote.logStatus remote key False
|
||||
return ok
|
||||
|
||||
{- Checks specified remotes to verify that enough copies of a key exist to
|
||||
|
|
|
@ -19,8 +19,9 @@ seek :: [CommandSeek]
|
|||
seek = [withKeys start]
|
||||
|
||||
start :: Key -> CommandStart
|
||||
start key = do
|
||||
present <- inAnnex key
|
||||
if present
|
||||
then stop
|
||||
else liftIO exitFailure
|
||||
start key = inAnnexSafe key >>= dispatch
|
||||
where
|
||||
dispatch (Just True) = stop
|
||||
dispatch (Just False) = exit 1
|
||||
dispatch Nothing = exit 100
|
||||
exit n = liftIO $ exitWith $ ExitFailure n
|
||||
|
|
|
@ -82,7 +82,7 @@ toPerform dest move key = moveLock move key $ do
|
|||
else Remote.hasKey dest key
|
||||
case isthere of
|
||||
Left err -> do
|
||||
showNote $ show err
|
||||
showNote $ err
|
||||
stop
|
||||
Right False -> do
|
||||
showAction $ "to " ++ Remote.name dest
|
||||
|
@ -96,7 +96,7 @@ toPerform dest move key = moveLock move key $ do
|
|||
Right True -> finish
|
||||
where
|
||||
finish = do
|
||||
Remote.remoteHasKey dest key True
|
||||
Remote.logStatus dest key True
|
||||
if move
|
||||
then do
|
||||
whenM (inAnnex key) $ removeAnnex key
|
||||
|
@ -137,5 +137,5 @@ fromPerform src move key = moveLock move key $ do
|
|||
{- Locks a key in order for it to be moved.
|
||||
- No lock is needed when a key is being copied. -}
|
||||
moveLock :: Bool -> Key -> Annex a -> Annex a
|
||||
moveLock True key a = lockExclusive key a
|
||||
moveLock True key a = lockContent key a
|
||||
moveLock False _ a = a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue