blob: 3068c30270de2e8acbb5c7caf35de09a245102c9 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
{- git-annex "URL" backend
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Backend.URL (backends) where
import Control.Monad.State (liftIO)
import Types
import BackendClass
import Utility
import Messages
import Key
backends :: [Backend Annex]
backends = [backend]
backend :: Backend Annex
backend = Backend {
name = "URL",
getKey = keyValue,
storeFileKey = dummyStore,
retrieveKeyFile = downloadUrl,
-- allow keys to be removed; presumably they can always be
-- downloaded again
removeKey = dummyRemove,
-- similarly, keys are always assumed to be out there on the web
hasKey = dummyOk,
-- and nothing needed to fsck
fsckKey = dummyFsck,
-- and key upgrade not needed
upgradableKey = \_ -> return False
}
-- cannot generate url from filename
keyValue :: FilePath -> Annex (Maybe Key)
keyValue _ = return Nothing
-- cannot change url contents
dummyStore :: FilePath -> Key -> Annex Bool
dummyStore _ _ = return False
dummyRemove :: Key -> Maybe a -> Annex Bool
dummyRemove _ _ = return True
dummyFsck :: Key -> Maybe FilePath -> Maybe a -> Annex Bool
dummyFsck _ _ _ = return True
dummyOk :: Key -> Annex Bool
dummyOk _ = return True
downloadUrl :: Key -> FilePath -> Annex Bool
downloadUrl key file = do
showNote $ "downloading"
showProgress -- make way for curl progress bar
liftIO $ boolSystem "curl" [Params "-# -o", File file, File url]
where
url = keyName key
|