split up Types
This commit is contained in:
parent
de3dafae80
commit
af82586adf
11 changed files with 49 additions and 55 deletions
19
Annex.hs
19
Annex.hs
|
@ -8,11 +8,28 @@ import System.Directory
|
||||||
import GitRepo
|
import GitRepo
|
||||||
import Utility
|
import Utility
|
||||||
import Locations
|
import Locations
|
||||||
import Types
|
|
||||||
import Backend
|
import Backend
|
||||||
import BackendList
|
import BackendList
|
||||||
import LocationLog
|
import LocationLog
|
||||||
|
|
||||||
|
-- git-annex's runtime state
|
||||||
|
data State = State {
|
||||||
|
repo :: GitRepo,
|
||||||
|
gitconfig :: GitConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
data GitConfig = GitConfig {
|
||||||
|
annex_name :: String,
|
||||||
|
annex_numcopies :: Int,
|
||||||
|
annex_backends :: [Backend]
|
||||||
|
}
|
||||||
|
|
||||||
|
{- An annexed file's content is stored somewhere under .git/annex/ -}
|
||||||
|
annexDir :: GitRepo -> Key -> IO FilePath
|
||||||
|
annexDir repo key = do
|
||||||
|
dir <- gitDir repo
|
||||||
|
return $ dir ++ "/annex/" ++ key
|
||||||
|
|
||||||
{- On startup, examine the git repo, prepare it, and record state for
|
{- On startup, examine the git repo, prepare it, and record state for
|
||||||
- later. -}
|
- later. -}
|
||||||
startAnnex :: IO State
|
startAnnex :: IO State
|
||||||
|
|
18
Backend.hs
18
Backend.hs
|
@ -22,7 +22,23 @@ import System.Directory
|
||||||
import Locations
|
import Locations
|
||||||
import GitRepo
|
import GitRepo
|
||||||
import Utility
|
import Utility
|
||||||
import Types
|
|
||||||
|
-- annexed filenames are mapped into keys
|
||||||
|
type Key = FilePath
|
||||||
|
|
||||||
|
-- this structure represents a key/value backend
|
||||||
|
data Backend = Backend {
|
||||||
|
-- name of this backend
|
||||||
|
name :: String,
|
||||||
|
-- converts a filename to a key
|
||||||
|
getKey :: GitRepo -> FilePath -> IO (Maybe Key),
|
||||||
|
-- stores a file's contents to a key
|
||||||
|
storeFileKey :: GitRepo -> FilePath -> Key -> IO Bool,
|
||||||
|
-- retrieves a key's contents to a file
|
||||||
|
retrieveKeyFile :: Key -> FilePath -> IO Bool,
|
||||||
|
-- removes a key
|
||||||
|
removeKey :: Key -> IO Bool
|
||||||
|
}
|
||||||
|
|
||||||
instance Show Backend where
|
instance Show Backend where
|
||||||
show backend = "Backend { name =\"" ++ (name backend) ++ "\" }"
|
show backend = "Backend { name =\"" ++ (name backend) ++ "\" }"
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
module BackendChecksum (backend) where
|
module BackendChecksum (backend) where
|
||||||
|
|
||||||
import Types
|
|
||||||
import qualified BackendFile
|
import qualified BackendFile
|
||||||
import Data.Digest.Pure.SHA
|
import Data.Digest.Pure.SHA
|
||||||
|
import Backend
|
||||||
|
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 {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
module BackendFile (backend) where
|
module BackendFile (backend) where
|
||||||
|
|
||||||
import Types
|
import Backend
|
||||||
|
import GitRepo
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
name = "file",
|
name = "file",
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
module BackendList where
|
module BackendList where
|
||||||
|
|
||||||
|
import Backend
|
||||||
|
|
||||||
-- When adding a new backend, import it here and add it to the list.
|
-- When adding a new backend, import it here and add it to the list.
|
||||||
import Types
|
|
||||||
import qualified BackendFile
|
import qualified BackendFile
|
||||||
import qualified BackendChecksum
|
import qualified BackendChecksum
|
||||||
import qualified BackendUrl
|
import qualified BackendUrl
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
module BackendUrl (backend) where
|
module BackendUrl (backend) where
|
||||||
|
|
||||||
import Types
|
import Backend
|
||||||
|
import GitRepo
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
name = "url",
|
name = "url",
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
module CmdLine where
|
module CmdLine where
|
||||||
|
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
import Types
|
|
||||||
import Annex
|
import Annex
|
||||||
|
|
||||||
data Mode = Add | Push | Pull | Want | Get | Drop | Unannex
|
data Mode = Add | Push | Pull | Want | Get | Drop | Unannex
|
||||||
|
|
|
@ -10,7 +10,12 @@ import System.IO
|
||||||
import Data.String.Utils
|
import Data.String.Utils
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Utility
|
import Utility
|
||||||
import Types
|
|
||||||
|
-- a git repository
|
||||||
|
data GitRepo = GitRepo {
|
||||||
|
top :: FilePath,
|
||||||
|
bare :: Bool
|
||||||
|
}
|
||||||
|
|
||||||
{- GitRepo constructor -}
|
{- GitRepo constructor -}
|
||||||
gitRepo :: FilePath -> IO GitRepo
|
gitRepo :: FilePath -> IO GitRepo
|
||||||
|
|
|
@ -28,7 +28,6 @@ import Data.Char
|
||||||
import GitRepo
|
import GitRepo
|
||||||
import Utility
|
import Utility
|
||||||
import Locations
|
import Locations
|
||||||
import Types
|
|
||||||
|
|
||||||
data LogLine = LogLine {
|
data LogLine = LogLine {
|
||||||
date :: POSIXTime,
|
date :: POSIXTime,
|
||||||
|
|
|
@ -3,15 +3,8 @@
|
||||||
|
|
||||||
module Locations where
|
module Locations where
|
||||||
|
|
||||||
import Types
|
|
||||||
import GitRepo
|
import GitRepo
|
||||||
|
|
||||||
{- An annexed file's content is stored somewhere under .git/annex/ -}
|
|
||||||
annexDir :: GitRepo -> Key -> IO FilePath
|
|
||||||
annexDir repo key = do
|
|
||||||
dir <- gitDir repo
|
|
||||||
return $ dir ++ "/annex/" ++ key
|
|
||||||
|
|
||||||
{- Long-term, cross-repo state is stored in files inside the .git-annex
|
{- Long-term, cross-repo state is stored in files inside the .git-annex
|
||||||
- directory, in the git repository. -}
|
- directory, in the git repository. -}
|
||||||
stateLoc = ".git-annex"
|
stateLoc = ".git-annex"
|
||||||
|
|
39
Types.hs
39
Types.hs
|
@ -1,39 +0,0 @@
|
||||||
{- git-annex data types
|
|
||||||
- -}
|
|
||||||
|
|
||||||
module Types where
|
|
||||||
|
|
||||||
-- annexed filenames are mapped into keys
|
|
||||||
type Key = String
|
|
||||||
|
|
||||||
-- this structure represents a key/value backend
|
|
||||||
data Backend = Backend {
|
|
||||||
-- name of this backend
|
|
||||||
name :: String,
|
|
||||||
-- converts a filename to a key
|
|
||||||
getKey :: GitRepo -> FilePath -> IO (Maybe Key),
|
|
||||||
-- stores a file's contents to a key
|
|
||||||
storeFileKey :: GitRepo -> FilePath -> Key -> IO Bool,
|
|
||||||
-- retrieves a key's contents to a file
|
|
||||||
retrieveKeyFile :: Key -> FilePath -> IO Bool,
|
|
||||||
-- removes a key
|
|
||||||
removeKey :: Key -> IO Bool
|
|
||||||
}
|
|
||||||
|
|
||||||
-- a git repository
|
|
||||||
data GitRepo = GitRepo {
|
|
||||||
top :: FilePath,
|
|
||||||
bare :: Bool
|
|
||||||
}
|
|
||||||
|
|
||||||
-- git-annex's runtime state
|
|
||||||
data State = State {
|
|
||||||
repo :: GitRepo,
|
|
||||||
gitconfig :: GitConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
data GitConfig = GitConfig {
|
|
||||||
annex_name :: String,
|
|
||||||
annex_numcopies :: Int,
|
|
||||||
annex_backends :: [Backend]
|
|
||||||
}
|
|
Loading…
Reference in a new issue