update
This commit is contained in:
parent
eb577ee37f
commit
7880dc16fe
4 changed files with 24 additions and 18 deletions
|
@ -28,9 +28,9 @@ data Backend = Backend {
|
|||
-- name of this backend
|
||||
name :: String,
|
||||
-- converts a filename to a key
|
||||
getKey :: FilePath -> IO (Maybe Key),
|
||||
getKey :: GitRepo -> FilePath -> IO (Maybe Key),
|
||||
-- stores a file's contents to a key
|
||||
storeFileKey :: FilePath -> Key -> IO (Bool),
|
||||
storeFileKey :: GitRepo -> FilePath -> Key -> IO (Bool),
|
||||
-- retrieves a key's contents to a file
|
||||
retrieveKeyFile :: IO Key -> FilePath -> IO (Bool)
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ backendFile backend repo file = gitStateDir repo ++
|
|||
storeFile :: [Backend] -> GitRepo -> FilePath -> IO (Maybe Key)
|
||||
storeFile [] _ _ = return Nothing
|
||||
storeFile (b:bs) repo file = do
|
||||
try <- (getKey b) (gitRelative repo file)
|
||||
try <- (getKey b) repo (gitRelative repo file)
|
||||
case (try) of
|
||||
Nothing -> nextbackend
|
||||
Just key -> do
|
||||
stored <- (storeFileKey b) file key
|
||||
stored <- (storeFileKey b) repo file key
|
||||
if (not stored)
|
||||
then nextbackend
|
||||
else do
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module BackendChecksum (backend) where
|
||||
|
||||
import Backend
|
||||
import GitRepo
|
||||
import qualified BackendFile
|
||||
import Data.Digest.Pure.SHA
|
||||
|
||||
|
@ -13,6 +14,6 @@ backend = BackendFile.backend {
|
|||
getKey = keyValue
|
||||
}
|
||||
|
||||
--
|
||||
keyValue :: FilePath -> IO (Maybe Key)
|
||||
keyValue k = error "unimplemented" -- TODO
|
||||
-- checksum the file to get its key
|
||||
keyValue :: GitRepo -> FilePath -> IO (Maybe Key)
|
||||
keyValue k = error "checksum keyValue unimplemented" -- TODO
|
||||
|
|
|
@ -4,20 +4,24 @@
|
|||
module BackendFile (backend) where
|
||||
|
||||
import Backend
|
||||
import GitRepo
|
||||
|
||||
backend = Backend {
|
||||
name = "file",
|
||||
getKey = keyValue,
|
||||
storeFileKey = moveToAnnex,
|
||||
storeFileKey = dummyStore,
|
||||
retrieveKeyFile = copyFromOtherRepo
|
||||
}
|
||||
|
||||
-- direct mapping from filename to key
|
||||
keyValue :: FilePath -> IO (Maybe Key)
|
||||
keyValue k = return $ Just $ id k
|
||||
keyValue :: GitRepo -> FilePath -> IO (Maybe Key)
|
||||
keyValue repo file = return $ Just file
|
||||
|
||||
moveToAnnex :: FilePath -> Key -> IO (Bool)
|
||||
moveToAnnex file key = return False
|
||||
-- This backend does not really do any independant data storage,
|
||||
-- it relies on the file contents in .git/annex/ in this repo,
|
||||
-- and other accessible repos. So storing a file is a no-op.
|
||||
dummyStore :: GitRepo -> FilePath -> Key -> IO (Bool)
|
||||
dummyStore repo file key = return True
|
||||
|
||||
copyFromOtherRepo :: IO Key -> FilePath -> IO (Bool)
|
||||
copyFromOtherRepo key file = return False
|
||||
copyFromOtherRepo key file = error "copyFromOtherRepo unimplemented" -- TODO
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module BackendUrl (backend) where
|
||||
|
||||
import Backend
|
||||
import GitRepo
|
||||
|
||||
backend = Backend {
|
||||
name = "url",
|
||||
|
@ -13,12 +14,12 @@ backend = Backend {
|
|||
}
|
||||
|
||||
-- cannot generate url from filename
|
||||
keyValue :: FilePath -> IO (Maybe Key)
|
||||
keyValue k = return Nothing
|
||||
keyValue :: GitRepo -> FilePath -> IO (Maybe Key)
|
||||
keyValue repo file = return Nothing
|
||||
|
||||
-- cannot store to urls
|
||||
dummyStore :: FilePath -> Key -> IO (Bool)
|
||||
dummyStore file url = return False
|
||||
dummyStore :: GitRepo -> FilePath -> Key -> IO (Bool)
|
||||
dummyStore repo file url = return False
|
||||
|
||||
downloadUrl :: IO Key -> FilePath -> IO (Bool)
|
||||
downloadUrl url file = error "unimplemented"
|
||||
downloadUrl url file = error "downloadUrl unimplemented"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue