diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-07-05 16:34:39 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-07-05 16:34:39 -0400 |
commit | c8256b6cbb8853f0cea09582e98978082cdd3cc8 (patch) | |
tree | d3d7d58ec4e676d3681a2196008826cba48b4d63 /Remote | |
parent | dc110d9bb3982f6bdf21e95941f3ef8a04d9f5a3 (diff) |
testremote: Fix crash when testing a freshly made external special remote.
Ignore exceptions when getting the cost and availability for the remote,
and return sane defaults. These defaults are not cached, so if a special
remote program has a transient problem, it will re-query it later.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/External.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Remote/External.hs b/Remote/External.hs index 619af60c1..9caf48aae 100644 --- a/Remote/External.hs +++ b/Remote/External.hs @@ -461,16 +461,17 @@ checkPrepared lck external = - external special remote every time time just to ask it what its - cost is. -} getCost :: External -> Git.Repo -> RemoteGitConfig -> Annex Cost -getCost external r gc = go =<< remoteCost' gc +getCost external r gc = catchNonAsync (go =<< remoteCost' gc) (const defcst) where go (Just c) = return c go Nothing = do c <- handleRequest external GETCOST Nothing $ \req -> case req of COST c -> Just $ return c - UNSUPPORTED_REQUEST -> Just $ return expensiveRemoteCost + UNSUPPORTED_REQUEST -> Just defcst _ -> Nothing setRemoteCost r c return c + defcst = return expensiveRemoteCost {- Caches the availability in the git config to avoid needing to start up an - external special remote every time time just to ask it what its @@ -480,15 +481,17 @@ getCost external r gc = go =<< remoteCost' gc - globally available is the default. -} getAvailability :: External -> Git.Repo -> RemoteGitConfig -> Annex Availability -getAvailability external r gc = maybe query return (remoteAnnexAvailability gc) +getAvailability external r gc = + maybe (catchNonAsync query (const defavail)) return (remoteAnnexAvailability gc) where query = do avail <- handleRequest external GETAVAILABILITY Nothing $ \req -> case req of AVAILABILITY avail -> Just $ return avail - UNSUPPORTED_REQUEST -> Just $ return GloballyAvailable + UNSUPPORTED_REQUEST -> Just defavail _ -> Nothing setRemoteAvailability r avail return avail + defavail = return GloballyAvailable claimurl :: External -> URLString -> Annex Bool claimurl external url = |