diff options
author | Joey Hess <joey@kitenet.net> | 2013-07-18 14:11:56 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-07-18 14:20:57 -0400 |
commit | 265fb05852816fbaa1ab8ebfee8d4187d156e33c (patch) | |
tree | 9c3f115ee9a88814cb751e80fbbba5204fefd289 /Remote | |
parent | fe0dbbabc3208c79eab8390e2789ea2fc2e02981 (diff) |
Fix checking when content is present in a non-bare repository accessed via http.
I thought at first this was a Windows specific problem, but it's not;
this affects checking any non-bare repository exported via http. Which is
a potentially important use case!
The actual bug was the case where Right False was returned by the first url
short-curcuited later checks. But the whole method used felt like code
I'd no longer write, and the use of undefined was particularly disgusting.
So I rewrote it.
Also added an action display.
This commit was sponsored by Eric Hanchrow. Thanks!
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/Git.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index b1f83b572..a857d5c14 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -228,17 +228,14 @@ inAnnex r key | Git.repoIsUrl r = checkremote | otherwise = checklocal where - checkhttp headers = liftIO $ go undefined $ keyUrls r key - where - go e [] = return $ Left e - go _ (u:us) = do - res <- catchMsgIO $ - Url.check u headers (keySize key) - case res of - Left e -> go e us - v -> return v + checkhttp headers = do + showchecking + liftIO $ ifM (anyM (\u -> Url.check u headers (keySize key)) (keyUrls r key)) + ( return $ Right True + , return $ Left "not found" + ) checkremote = do - showAction $ "checking " ++ Git.repoDescribe r + showchecking onRemote r (check, unknown) "inannex" [Param (key2file key)] [] where check c p = dispatch <$> safeSystem c p @@ -253,6 +250,7 @@ inAnnex r key dispatch (Right (Just b)) = Right b dispatch (Right Nothing) = unknown unknown = Left $ "unable to check " ++ Git.repoDescribe r + showchecking = showAction $ "checking " ++ Git.repoDescribe r {- Runs an action on a local repository inexpensively, by making an annex - monad using that repository. -} |