diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-08-17 11:35:34 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-08-17 11:35:34 -0400 |
commit | 858104078a3289debad8b28ceb831be9abbbf1e9 (patch) | |
tree | 7c8963ae5904c1858f53fd07653412d37e349d5e /Command/Whereis.hs | |
parent | 3a5b7dbaf0e984f596b813ce87323d7350b3db8b (diff) |
make whereis show urls when web remote does not have content
This is needed when external special remotes register an url for a key.
Diffstat (limited to 'Command/Whereis.hs')
-rw-r--r-- | Command/Whereis.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Command/Whereis.hs b/Command/Whereis.hs index 3610eed788..7b8bdf351a 100644 --- a/Command/Whereis.hs +++ b/Command/Whereis.hs @@ -14,6 +14,7 @@ import Command import Remote import Logs.Trust import Logs.Web +import Remote.Web (getWebUrls) cmd :: Command cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $ @@ -60,6 +61,11 @@ perform remotemap key = do unless (null safelocations) $ showLongNote pp pp' <- prettyPrintUUIDs "untrusted" untrustedlocations unless (null untrustedlocations) $ showLongNote $ untrustedheader ++ pp' + + -- Since other remotes than the web remote can set urls + -- where a key can be downloaded, get and show all such urls + -- as a special case. + showRemote "web" =<< getWebUrls key forM_ (mapMaybe (`M.lookup` remotemap) locations) $ performRemote key if null safelocations then stop else next $ return True @@ -73,8 +79,7 @@ performRemote key remote = do ls <- (++) <$> askremote <*> claimedurls - unless (null ls) $ showLongNote $ unlines $ - map (\l -> name remote ++ ": " ++ l) ls + showRemote (name remote) ls where askremote = maybe (pure []) (flip id key) (whereisKey remote) claimedurls = do @@ -83,3 +88,9 @@ performRemote key remote = do . map getDownloader <$> getUrls key filterM (\u -> (==) <$> pure remote <*> claimingUrl u) us + +showRemote :: String -> [String] -> Annex () +showRemote n ls + | null ls = return () + | otherwise = showLongNote $ unlines $ + map (\l -> n ++ ": " ++ l) ls |