add: avoid ugly error message when adding a deleted file in direct mode

Due to add using withFilesMaybeModified, it will get files that have been
deleted but are still in the index. So catch the IO error that results when
trying to stat such a file.
This commit is contained in:
Joey Hess 2013-04-23 17:22:56 -04:00
parent 07580dc3df
commit 8b0dcb3136

View file

@ -56,12 +56,14 @@ start :: FilePath -> CommandStart
start file = ifAnnexed file addpresent add
where
add = do
s <- liftIO $ getSymbolicLinkStatus file
if isSymbolicLink s || not (isRegularFile s)
then stop
else do
showStart "add" file
next $ perform file
ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
case ms of
Nothing -> stop
Just s
| isSymbolicLink s || not (isRegularFile s) -> stop
| otherwise -> do
showStart "add" file
next $ perform file
addpresent (key, _) = ifM isDirect
( ifM (goodContent key file) ( stop , add )
, fixup key