move some code around
This commit is contained in:
parent
9b746ee588
commit
3dac026598
1 changed files with 15 additions and 15 deletions
30
Locations.hs
30
Locations.hs
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex file locations
|
{- git-annex file locations
|
||||||
-
|
-
|
||||||
- Copyright 2010-2011 Joey Hess <joey@kitenet.net>
|
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -293,13 +293,26 @@ isLinkToAnnex s = (pathSeparator:objectDir) `isInfixOf` s
|
||||||
- a slash
|
- a slash
|
||||||
- "%" is escaped to "&s", and "&" to "&a"; this ensures that the mapping
|
- "%" is escaped to "&s", and "&" to "&a"; this ensures that the mapping
|
||||||
- is one to one.
|
- is one to one.
|
||||||
- ":" is escaped to "&c", because despite it being 2011, people still care
|
- ":" is escaped to "&c", because despite it being 20XX people still care
|
||||||
- about FAT.
|
- about FAT.
|
||||||
-}
|
-}
|
||||||
keyFile :: Key -> FilePath
|
keyFile :: Key -> FilePath
|
||||||
keyFile key = replace "/" "%" $ replace ":" "&c" $
|
keyFile key = replace "/" "%" $ replace ":" "&c" $
|
||||||
replace "%" "&s" $ replace "&" "&a" $ key2file key
|
replace "%" "&s" $ replace "&" "&a" $ key2file key
|
||||||
|
|
||||||
|
{- Reverses keyFile, converting a filename fragment (ie, the basename of
|
||||||
|
- the symlink target) into a key. -}
|
||||||
|
fileKey :: FilePath -> Maybe Key
|
||||||
|
fileKey file = file2key $
|
||||||
|
replace "&a" "&" $ replace "&s" "%" $
|
||||||
|
replace "&c" ":" $ replace "%" "/" file
|
||||||
|
|
||||||
|
{- for quickcheck -}
|
||||||
|
prop_idempotent_fileKey :: String -> Bool
|
||||||
|
prop_idempotent_fileKey s = Just k == fileKey (keyFile k)
|
||||||
|
where
|
||||||
|
k = stubKey { keyName = s, keyBackendName = "test" }
|
||||||
|
|
||||||
{- A location to store a key on the filesystem. A directory hash is used,
|
{- A location to store a key on the filesystem. A directory hash is used,
|
||||||
- to protect against filesystems that dislike having many items in a
|
- to protect against filesystems that dislike having many items in a
|
||||||
- single directory.
|
- single directory.
|
||||||
|
@ -316,19 +329,6 @@ keyPath key hasher = hasher key </> f </> f
|
||||||
keyPaths :: Key -> [FilePath]
|
keyPaths :: Key -> [FilePath]
|
||||||
keyPaths key = map (keyPath key) annexHashes
|
keyPaths key = map (keyPath key) annexHashes
|
||||||
|
|
||||||
{- Reverses keyFile, converting a filename fragment (ie, the basename of
|
|
||||||
- the symlink target) into a key. -}
|
|
||||||
fileKey :: FilePath -> Maybe Key
|
|
||||||
fileKey file = file2key $
|
|
||||||
replace "&a" "&" $ replace "&s" "%" $
|
|
||||||
replace "&c" ":" $ replace "%" "/" file
|
|
||||||
|
|
||||||
{- for quickcheck -}
|
|
||||||
prop_idempotent_fileKey :: String -> Bool
|
|
||||||
prop_idempotent_fileKey s = Just k == fileKey (keyFile k)
|
|
||||||
where
|
|
||||||
k = stubKey { keyName = s, keyBackendName = "test" }
|
|
||||||
|
|
||||||
{- Two different directory hashes may be used. The mixed case hash
|
{- Two different directory hashes may be used. The mixed case hash
|
||||||
- came first, and is fine, except for the problem of case-strict
|
- came first, and is fine, except for the problem of case-strict
|
||||||
- filesystems such as Linux VFAT (mounted with shortname=mixed),
|
- filesystems such as Linux VFAT (mounted with shortname=mixed),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue