diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-09 15:05:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-09 15:05:08 -0400 |
commit | 75d29250823326c8b4894a855927f65b5fdf4e13 (patch) | |
tree | a888b86d8e0569b9e1c388700dd6717aaa175834 /Locations.hs | |
parent | 377bf24d9a951186b374cd7a3f920b6bc9deb8f1 (diff) | |
parent | 8d5374f4a33f398baa166035e5fafb716a78fd1d (diff) |
Merge branch 'master' into checkout
Conflicts:
debian/changelog
doc/backends.mdwn
Diffstat (limited to 'Locations.hs')
-rw-r--r-- | Locations.hs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/Locations.hs b/Locations.hs index 951924c40..58244cef0 100644 --- a/Locations.hs +++ b/Locations.hs @@ -13,7 +13,10 @@ module Locations ( annexLocation, annexLocationRelative, annexTmpLocation, - annexDir + annexDir, + annexObjectDir, + + prop_idempotent_fileKey ) where import Data.String.Utils @@ -28,12 +31,7 @@ stateLoc = ".git-annex/" gitStateDir :: Git.Repo -> FilePath gitStateDir repo = (Git.workTree repo) ++ "/" ++ stateLoc -{- An annexed file's content is stored in - - /path/to/repo/.git/annex/<key>, where <key> is of the form - - <backend:fragment> - - - - That allows deriving the key and backend by looking at the symlink to it. - -} +{- Annexed file's absolute location. -} annexLocation :: Git.Repo -> Key -> FilePath annexLocation r key = (Git.workTree r) ++ "/" ++ (annexLocationRelative key) @@ -42,7 +40,9 @@ annexLocation r key = - - Note: Assumes repo is NOT bare.-} annexLocationRelative :: Key -> FilePath -annexLocationRelative key = ".git/annex/" ++ (keyFile key) +annexLocationRelative key = ".git/annex/objects/" ++ f ++ "/" ++ f + where + f = keyFile key {- The annex directory of a repository. - @@ -50,6 +50,11 @@ annexLocationRelative key = ".git/annex/" ++ (keyFile key) annexDir :: Git.Repo -> FilePath annexDir r = Git.workTree r ++ "/.git/annex" +{- The part of the annex directory where file contents are stored. + -} +annexObjectDir :: Git.Repo -> FilePath +annexObjectDir r = annexDir r ++ "/objects" + {- .git-annex/tmp is used for temp files -} annexTmpLocation :: Git.Repo -> FilePath annexTmpLocation r = annexDir r ++ "/tmp/" @@ -65,10 +70,15 @@ annexTmpLocation r = annexDir r ++ "/tmp/" - is one to one. - -} keyFile :: Key -> FilePath -keyFile key = replace "/" "%" $ replace "%" "&s" $ replace "&" "&a" $ show key +keyFile key = replace "/" "%" $ replace "%" "&s" $ replace "&" "&a" $ show key {- Reverses keyFile, converting a filename fragment (ie, the basename of - the symlink target) into a key. -} fileKey :: FilePath -> Key fileKey file = read $ replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file + +{- for quickcheck -} +prop_idempotent_fileKey :: String -> Bool +prop_idempotent_fileKey s = k == (fileKey $ keyFile k) + where k = read $ "test:" ++ s |