make whereis show urls when web remote does not have content
This is needed when external special remotes register an url for a key.
This commit is contained in:
parent
3a5b7dbaf0
commit
858104078a
2 changed files with 15 additions and 4 deletions
|
@ -14,6 +14,7 @@ import Command
|
||||||
import Remote
|
import Remote
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
|
import Remote.Web (getWebUrls)
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
|
cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
|
||||||
|
@ -60,6 +61,11 @@ perform remotemap key = do
|
||||||
unless (null safelocations) $ showLongNote pp
|
unless (null safelocations) $ showLongNote pp
|
||||||
pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
|
pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
|
||||||
unless (null untrustedlocations) $ showLongNote $ untrustedheader ++ pp'
|
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) $
|
forM_ (mapMaybe (`M.lookup` remotemap) locations) $
|
||||||
performRemote key
|
performRemote key
|
||||||
if null safelocations then stop else next $ return True
|
if null safelocations then stop else next $ return True
|
||||||
|
@ -73,8 +79,7 @@ performRemote key remote = do
|
||||||
ls <- (++)
|
ls <- (++)
|
||||||
<$> askremote
|
<$> askremote
|
||||||
<*> claimedurls
|
<*> claimedurls
|
||||||
unless (null ls) $ showLongNote $ unlines $
|
showRemote (name remote) ls
|
||||||
map (\l -> name remote ++ ": " ++ l) ls
|
|
||||||
where
|
where
|
||||||
askremote = maybe (pure []) (flip id key) (whereisKey remote)
|
askremote = maybe (pure []) (flip id key) (whereisKey remote)
|
||||||
claimedurls = do
|
claimedurls = do
|
||||||
|
@ -83,3 +88,9 @@ performRemote key remote = do
|
||||||
. map getDownloader
|
. map getDownloader
|
||||||
<$> getUrls key
|
<$> getUrls key
|
||||||
filterM (\u -> (==) <$> pure remote <*> claimingUrl u) us
|
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
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Remote.Web (remote) where
|
module Remote.Web (remote, getWebUrls) where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
|
@ -54,7 +54,7 @@ gen r _ c gc =
|
||||||
, removeKey = dropKey
|
, removeKey = dropKey
|
||||||
, checkPresent = checkKey
|
, checkPresent = checkKey
|
||||||
, checkPresentCheap = False
|
, checkPresentCheap = False
|
||||||
, whereisKey = Just getWebUrls
|
, whereisKey = Nothing
|
||||||
, remoteFsck = Nothing
|
, remoteFsck = Nothing
|
||||||
, repairRepo = Nothing
|
, repairRepo = Nothing
|
||||||
, config = c
|
, config = c
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue