git-annex/BackendUrl.hs
Joey Hess d1071bd1fe autobugfixing!
Converted Key to a real data type and caught all the places where I used
an unconverted filename as a key.

Had to loose some sanity checks around whether something is already
annexed, but I guess I can add those back other ways.
2010-10-13 02:31:24 -04:00

34 lines
828 B
Haskell

{- 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