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