more state
This commit is contained in:
parent
2ac47a3a59
commit
20acda0423
5 changed files with 12 additions and 14 deletions
|
@ -68,7 +68,7 @@ retrieveFile backends state file dest = do
|
||||||
Nothing -> return False
|
Nothing -> return False
|
||||||
Just b -> do
|
Just b -> do
|
||||||
key <- lookupKey b state file
|
key <- lookupKey b state file
|
||||||
(retrieveKeyFile b) key dest
|
(retrieveKeyFile b) state key dest
|
||||||
|
|
||||||
{- Drops the key for a file from the backend that has it. -}
|
{- Drops the key for a file from the backend that has it. -}
|
||||||
dropFile :: [Backend] -> State -> FilePath -> IO (Maybe Key)
|
dropFile :: [Backend] -> State -> FilePath -> IO (Maybe Key)
|
||||||
|
@ -78,7 +78,7 @@ dropFile backends state file = do
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
Just b -> do
|
Just b -> do
|
||||||
key <- lookupKey b state file
|
key <- lookupKey b state file
|
||||||
(removeKey b) key
|
(removeKey b) state key
|
||||||
removeFile $ backendFile b state file
|
removeFile $ backendFile b state file
|
||||||
return $ Just key
|
return $ Just key
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ module BackendChecksum (backend) where
|
||||||
import qualified BackendFile
|
import qualified BackendFile
|
||||||
import Data.Digest.Pure.SHA
|
import Data.Digest.Pure.SHA
|
||||||
import Types
|
import Types
|
||||||
import GitRepo
|
|
||||||
|
|
||||||
-- based on BackendFile just with a different key type
|
-- based on BackendFile just with a different key type
|
||||||
backend = BackendFile.backend {
|
backend = BackendFile.backend {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
module BackendFile (backend) where
|
module BackendFile (backend) where
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import GitRepo
|
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
name = "file",
|
name = "file",
|
||||||
|
@ -24,10 +23,10 @@ keyValue state file = return $ Just file
|
||||||
- a no-op. -}
|
- a no-op. -}
|
||||||
dummyStore :: State -> FilePath -> Key -> IO (Bool)
|
dummyStore :: State -> FilePath -> Key -> IO (Bool)
|
||||||
dummyStore state file key = return True
|
dummyStore state file key = return True
|
||||||
dummyRemove :: Key -> IO Bool
|
dummyRemove :: State -> Key -> IO Bool
|
||||||
dummyRemove url = return False
|
dummyRemove state url = return False
|
||||||
|
|
||||||
{- Try to find a copy of the file in one of the other repos,
|
{- Try to find a copy of the file in one of the other repos,
|
||||||
- and copy it over to this one. -}
|
- and copy it over to this one. -}
|
||||||
copyFromOtherRepo :: Key -> FilePath -> IO (Bool)
|
copyFromOtherRepo :: State -> Key -> FilePath -> IO (Bool)
|
||||||
copyFromOtherRepo key file = error "copyFromOtherRepo unimplemented" -- TODO
|
copyFromOtherRepo state key file = error "copyFromOtherRepo unimplemented" -- TODO
|
||||||
|
|
|
@ -20,8 +20,8 @@ keyValue repo file = return Nothing
|
||||||
-- cannot change urls
|
-- cannot change urls
|
||||||
dummyStore :: State -> FilePath -> Key -> IO Bool
|
dummyStore :: State -> FilePath -> Key -> IO Bool
|
||||||
dummyStore repo file url = return False
|
dummyStore repo file url = return False
|
||||||
dummyRemove :: Key -> IO Bool
|
dummyRemove :: State -> Key -> IO Bool
|
||||||
dummyRemove url = return False
|
dummyRemove state url = return False
|
||||||
|
|
||||||
downloadUrl :: Key -> FilePath -> IO Bool
|
downloadUrl :: State -> Key -> FilePath -> IO Bool
|
||||||
downloadUrl url file = error "downloadUrl unimplemented"
|
downloadUrl state url file = error "downloadUrl unimplemented"
|
||||||
|
|
4
Types.hs
4
Types.hs
|
@ -26,9 +26,9 @@ data Backend = Backend {
|
||||||
-- stores a file's contents to a key
|
-- stores a file's contents to a key
|
||||||
storeFileKey :: State -> FilePath -> Key -> IO Bool,
|
storeFileKey :: State -> FilePath -> Key -> IO Bool,
|
||||||
-- retrieves a key's contents to a file
|
-- retrieves a key's contents to a file
|
||||||
retrieveKeyFile :: Key -> FilePath -> IO Bool,
|
retrieveKeyFile :: State -> Key -> FilePath -> IO Bool,
|
||||||
-- removes a key
|
-- removes a key
|
||||||
removeKey :: Key -> IO Bool
|
removeKey :: State -> Key -> IO Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Show Backend where
|
instance Show Backend where
|
||||||
|
|
Loading…
Reference in a new issue