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:
Joey Hess 2011-11-09 18:33:15 -04:00
parent 2934a65ac5
commit d3e1a3619f
14 changed files with 93 additions and 50 deletions

View file

@ -114,5 +114,9 @@ remove d k = liftIO $ catchBool $ do
file = dirKey d k
dir = parentDir file
checkPresent :: FilePath -> Key -> Annex (Either IOException Bool)
checkPresent d k = liftIO $ try $ doesFileExist (dirKey d k)
checkPresent :: FilePath -> Key -> Annex (Either String Bool)
checkPresent d k = dispatch <$> check
where
check = liftIO $ try $ doesFileExist (dirKey d k)
dispatch (Left e) = Left $ show e
dispatch (Right v) = Right v