lift to IO
This commit is contained in:
parent
946a7f3f21
commit
e67887d98b
2 changed files with 11 additions and 6 deletions
|
@ -26,12 +26,16 @@ import qualified Annex
|
||||||
import UUID
|
import UUID
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
|
name = mustProvide,
|
||||||
|
getKey = mustProvide,
|
||||||
storeFileKey = dummyStore,
|
storeFileKey = dummyStore,
|
||||||
retrieveKeyFile = copyKeyFile,
|
retrieveKeyFile = copyKeyFile,
|
||||||
removeKey = dummyRemove,
|
removeKey = dummyRemove,
|
||||||
hasKey = checkKeyFile
|
hasKey = checkKeyFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mustProvide = error "must provide this field"
|
||||||
|
|
||||||
{- Storing a key is a no-op. -}
|
{- Storing a key is a no-op. -}
|
||||||
dummyStore :: FilePath -> Key -> Annex (Bool)
|
dummyStore :: FilePath -> Key -> Annex (Bool)
|
||||||
dummyStore file key = return True
|
dummyStore file key = return True
|
||||||
|
@ -74,11 +78,12 @@ copyKeyFile key file = do
|
||||||
cantfind = do
|
cantfind = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
uuids <- liftIO $ keyLocations g key
|
uuids <- liftIO $ keyLocations g key
|
||||||
|
ppuuids <- prettyPrintUUIDs uuids
|
||||||
error $ "no available git remotes have: " ++
|
error $ "no available git remotes have: " ++
|
||||||
(keyFile key) ++ (uuidlist uuids)
|
(keyFile key) ++
|
||||||
uuidlist [] = ""
|
if (0 < length uuids)
|
||||||
uuidlist uuids = "\nIt has been seen before in these repositories:\n" ++
|
then "\nIt has been seen before in these repositories:\n" ++ ppuuids
|
||||||
prettyPrintUUIDs uuids
|
else ""
|
||||||
|
|
||||||
{- Tries to copy a file from a remote, exception on error. -}
|
{- Tries to copy a file from a remote, exception on error. -}
|
||||||
copyFromRemote :: Git.Repo -> Key -> FilePath -> IO ()
|
copyFromRemote :: Git.Repo -> Key -> FilePath -> IO ()
|
||||||
|
|
4
UUID.hs
4
UUID.hs
|
@ -91,7 +91,7 @@ reposByUUID repos uuids = do
|
||||||
|
|
||||||
{- Pretty-prints a list of UUIDs
|
{- Pretty-prints a list of UUIDs
|
||||||
- TODO: use lookup file to really show pretty names. -}
|
- TODO: use lookup file to really show pretty names. -}
|
||||||
prettyPrintUUIDs :: [UUID] -> String
|
prettyPrintUUIDs :: [UUID] -> Annex String
|
||||||
prettyPrintUUIDs uuids =
|
prettyPrintUUIDs uuids =
|
||||||
unwords $ map (\u -> "\tUUID "++u++"\n") uuids
|
return $ unwords $ map (\u -> "\tUUID "++u++"\n") uuids
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue