2010-10-10 19:54:02 +00:00
|
|
|
{- git-annex file locations
|
|
|
|
-}
|
|
|
|
|
2010-10-11 21:52:46 +00:00
|
|
|
module Locations (
|
|
|
|
gitStateDir,
|
2010-10-13 00:04:36 +00:00
|
|
|
stateLoc,
|
|
|
|
keyFile,
|
2010-10-13 04:42:46 +00:00
|
|
|
annexLocation
|
2010-10-11 21:52:46 +00:00
|
|
|
) where
|
2010-10-10 19:54:02 +00:00
|
|
|
|
2010-10-13 00:04:36 +00:00
|
|
|
import Data.String.Utils
|
|
|
|
import Types
|
2010-10-10 19:54:02 +00:00
|
|
|
import GitRepo
|
|
|
|
|
2010-10-11 04:23:49 +00:00
|
|
|
{- Long-term, cross-repo state is stored in files inside the .git-annex
|
2010-10-12 04:53:42 +00:00
|
|
|
- directory, in the git repository's working tree. -}
|
2010-10-10 19:54:02 +00:00
|
|
|
stateLoc = ".git-annex"
|
|
|
|
gitStateDir :: GitRepo -> FilePath
|
2010-10-12 04:53:42 +00:00
|
|
|
gitStateDir repo = (gitWorkTree repo) ++ "/" ++ stateLoc ++ "/"
|
2010-10-13 00:04:36 +00:00
|
|
|
|
2010-10-13 04:21:34 +00:00
|
|
|
{- Converts a key into a filename fragment.
|
2010-10-13 00:04:36 +00:00
|
|
|
- Just escape "/" in the key name, to keep a flat
|
|
|
|
- tree of files and avoid issues with files ending with "/" etc. -}
|
|
|
|
keyFile :: Key -> FilePath
|
2010-10-13 04:21:34 +00:00
|
|
|
keyFile key = replace "/" "&s" $ replace "&" "&a" key
|
2010-10-13 00:04:36 +00:00
|
|
|
|
2010-10-13 04:42:46 +00:00
|
|
|
{- An annexed file's content is stored in
|
|
|
|
- .git/annex/<backend>/<key> ; this allows deriving the key and backend
|
|
|
|
- by looking at the symlink to it. -}
|
|
|
|
annexLocation :: State -> Backend -> Key -> FilePath
|
|
|
|
annexLocation state backend key =
|
|
|
|
gitDir (repo state) ++ "/annex/" ++ (name backend) ++
|
|
|
|
"/" ++ (keyFile key)
|