Urls can now be claimed by remotes. This will allow creating, for example, a external special remote that handles magnet: and *.torrent urls.
This commit is contained in:
parent
ee27298b91
commit
30bf112185
28 changed files with 346 additions and 114 deletions
13
Remote.hs
13
Remote.hs
|
@ -45,7 +45,8 @@ module Remote (
|
|||
forceTrust,
|
||||
logStatus,
|
||||
checkAvailable,
|
||||
isXMPPRemote
|
||||
isXMPPRemote,
|
||||
claimingUrl,
|
||||
) where
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
@ -60,6 +61,7 @@ import Annex.UUID
|
|||
import Logs.UUID
|
||||
import Logs.Trust
|
||||
import Logs.Location hiding (logStatus)
|
||||
import Logs.Web
|
||||
import Remote.List
|
||||
import Config
|
||||
import Git.Types (RemoteName)
|
||||
|
@ -318,3 +320,12 @@ hasKey r k = either (Left . show) Right <$> tryNonAsync (checkPresent r k)
|
|||
|
||||
hasKeyCheap :: Remote -> Bool
|
||||
hasKeyCheap = checkPresentCheap
|
||||
|
||||
{- The web special remote claims urls by default. -}
|
||||
claimingUrl :: URLString -> Annex Remote
|
||||
claimingUrl url = do
|
||||
rs <- remoteList
|
||||
let web = Prelude.head $ filter (\r -> uuid r == webUUID) rs
|
||||
fromMaybe web <$> firstM checkclaim rs
|
||||
where
|
||||
checkclaim = maybe (pure False) (flip id url) . claimUrl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue