blob: 3acb28e29a9c16e4db8946555737b595f717b261 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{- Url claim checking.
-
- Copyright 2013-2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Annex.URLClaim (
URLClaim(..),
urlClaim
) where
import Common.Annex
import Types.URLClaim
import Logs.Web
import Remote
import qualified Types.Remote as Remote
urlClaim :: URLString -> Annex (Remote, URLClaim)
urlClaim url = do
rs <- remoteList
-- The web special remote claims urls by default.
let web = Prelude.head $ filter (\r -> uuid r == webUUID) rs
fromMaybe (web, URLClaimed) <$> getM (\r -> ret r <$> checkclaim r) rs
where
checkclaim = maybe (pure Nothing) (flip id url) . Remote.claimUrl
ret _ Nothing = Nothing
ret r (Just c) = Just (r, c)
|