aboutsummaryrefslogtreecommitdiff
path: root/Command/Whereis.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2014-12-08 19:14:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2014-12-08 19:15:07 -0400
commit929de31900dbc9654e0bcc1f4679f526aee7f99a (patch)
treed868a3bbae9a0af26191f461f317f6d40b08a2af /Command/Whereis.hs
parent28764ce2dc29d1d93989b4061b5b12bac10902de (diff)
Urls can now be claimed by remotes. This will allow creating, for example, a external special remote that handles magnet: and *.torrent urls.
Diffstat (limited to 'Command/Whereis.hs')
-rw-r--r--Command/Whereis.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 582aaffc2..314c204be 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -1,6 +1,6 @@
{- git-annex command
-
- - Copyright 2010 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -13,6 +13,7 @@ import Common.Annex
import Command
import Remote
import Logs.Trust
+import Logs.Web
cmd :: [Command]
cmd = [noCommit $ withOptions (jsonOption : keyOptions) $
@@ -57,9 +58,17 @@ perform remotemap key = do
untrustedheader = "The following untrusted locations may also have copies:\n"
performRemote :: Key -> Remote -> Annex ()
-performRemote key remote = maybe noop go $ whereisKey remote
+performRemote key remote = do
+ ls <- (++)
+ <$> askremote
+ <*> claimedurls
+ unless (null ls) $ showLongNote $ unlines $
+ map (\l -> name remote ++ ": " ++ l) ls
where
- go a = do
- ls <- a key
- unless (null ls) $ showLongNote $ unlines $
- map (\l -> name remote ++ ": " ++ l) ls
+ askremote = maybe (pure []) (flip id key) (whereisKey remote)
+ claimedurls = do
+ us <- map fst
+ . filter (\(_, d) -> d == OtherDownloader)
+ . map getDownloader
+ <$> getUrls key
+ filterM (\u -> (==) <$> pure remote <*> claimingUrl u) us