summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-23 17:22:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-23 17:22:56 -0400
commit2709a3507336ad4be1cc3dd34ac8f191700dcdf3 (patch)
tree3c3551e78faee447f9c29af91fb42bc4df6528d6
parent7b3dee7e718e8b19fb9b2458fc507ffb5f4fbcba (diff)
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.
-rw-r--r--Command/Add.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 2453e6842..fa7d48544 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -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