summaryrefslogtreecommitdiff
path: root/BackendUrl.hs
blob: 5b586497c4caede73ab9d5d02b71a4cc37d71b0e (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
{- git-annex "url" backend
 - -}

module BackendUrl (backend) where

import System.Cmd
import IO
import Types

backend = Backend {
	name = "url",
	getKey = keyValue,
	storeFileKey = dummyStore,
	retrieveKeyFile = downloadUrl,
	removeKey = dummyRemove
}

-- cannot generate url from filename
keyValue :: State -> FilePath -> IO (Maybe Key)
keyValue repo file = return Nothing

-- cannot change url contents
dummyStore :: State -> FilePath -> Key -> IO Bool
dummyStore repo file url = return False
dummyRemove :: State -> Key -> IO Bool
dummyRemove state url = return False

downloadUrl :: State -> Key -> FilePath -> IO Bool
downloadUrl state url file = do
	putStrLn $ "download: " ++ (show url)
	result <- try $ rawSystem "curl" ["-#", "-o", file, (show url)]
	case (result) of
		Left _ -> return False
		Right _ -> return True