git-annex/Backend/URL.hs

62 lines
1.4 KiB
Haskell
Raw Normal View History

2010-10-15 23:33:10 +00:00
{- git-annex "URL" backend
2010-10-27 20:53:54 +00:00
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
2010-10-10 17:47:04 +00:00
module Backend.URL (backends) where
2010-10-10 17:47:04 +00:00
2010-10-15 00:05:04 +00:00
import Control.Monad.State (liftIO)
2010-10-16 20:20:49 +00:00
import Types
2011-03-16 02:04:50 +00:00
import BackendClass
import Utility
2010-11-08 19:15:21 +00:00
import Messages
import Key
2010-10-10 17:47:04 +00:00
backends :: [Backend Annex]
backends = [backend]
backend :: Backend Annex
2010-10-10 17:47:04 +00:00
backend = Backend {
2010-10-15 23:33:10 +00:00
name = "URL",
2010-10-10 19:04:18 +00:00
getKey = keyValue,
storeFileKey = dummyStore,
2010-10-10 23:53:31 +00:00
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
2010-10-10 17:47:04 +00:00
}
-- cannot generate url from filename
2010-10-14 01:28:47 +00:00
keyValue :: FilePath -> Annex (Maybe Key)
2010-10-31 20:00:32 +00:00
keyValue _ = return Nothing
2010-10-10 17:47:04 +00:00
2010-10-12 21:26:34 +00:00
-- cannot change url contents
2010-10-14 01:28:47 +00:00
dummyStore :: FilePath -> Key -> Annex Bool
2010-10-31 20:00:32 +00:00
dummyStore _ _ = return False
2010-10-14 18:14:19 +00:00
dummyRemove :: Key -> Maybe a -> Annex Bool
dummyRemove _ _ = return True
dummyFsck :: Key -> Maybe FilePath -> Maybe a -> Annex Bool
dummyFsck _ _ _ = return True
2010-10-14 19:31:44 +00:00
dummyOk :: Key -> Annex Bool
2010-10-31 20:00:32 +00:00
dummyOk _ = return True
2010-10-10 19:04:18 +00:00
2010-10-14 01:28:47 +00:00
downloadUrl :: Key -> FilePath -> Annex Bool
2010-10-15 00:05:04 +00:00
downloadUrl key file = do
showNote $ "downloading"
showProgress -- make way for curl progress bar
liftIO $ boolSystem "curl" [Params "-# -o", File file, File url]
2010-10-15 00:05:04 +00:00
where
url = keyName key