summaryrefslogtreecommitdiff
path: root/Locations.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-13 01:04:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-13 01:04:06 -0400
commit16cd682290b065fee59575b077525d20713e4b4b (patch)
tree51e4392cb91a186db07c247004e99fff9ad46fd2 /Locations.hs
parent67ae9d7fa109503e4b798e2b7703282b92ce3deb (diff)
better key to file mapping
Diffstat (limited to 'Locations.hs')
-rw-r--r--Locations.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Locations.hs b/Locations.hs
index faf29235f..6aba0ed1a 100644
--- a/Locations.hs
+++ b/Locations.hs
@@ -20,10 +20,17 @@ gitStateDir :: GitRepo -> FilePath
gitStateDir repo = (gitWorkTree repo) ++ "/" ++ stateLoc ++ "/"
{- Converts a key into a filename fragment.
- - Just escape "/" in the key name, to keep a flat
- - tree of files and avoid issues with files ending with "/" etc. -}
+ -
+ - Escape "/" in the key name, to keep a flat tree of files and avoid
+ - issues with keys containing "/../" or ending with "/" etc.
+ -
+ - "/" is escaped to "%" because it's short and rarely used, and resembles
+ - a slash
+ - "%" is escaped to "&s", and "&" to "&a"; this ensures that the mapping
+ - is one to one.
+ - -}
keyFile :: Key -> FilePath
-keyFile key = replace "/" "&s" $ replace "&" "&a" key
+keyFile key = replace "/" "%" $ replace "%" "%s" $ replace "&" "&a" key
{- An annexed file's content is stored in
- .git/annex/<backend>/<key> ; this allows deriving the key and backend
@@ -32,6 +39,7 @@ annexLocation :: State -> Backend -> Key -> FilePath
annexLocation state backend key =
(gitWorkTree $ repo state) ++ "/" ++
(annexLocationRelative state backend key)
+
annexLocationRelative :: State -> Backend -> Key -> FilePath
annexLocationRelative state backend key =
gitDir (repo state) ++ "/annex/" ++ (name backend) ++