refactor
This commit is contained in:
parent
e6ef66cea3
commit
bff6ca2634
2 changed files with 12 additions and 13 deletions
11
Locations.hs
11
Locations.hs
|
@ -20,6 +20,7 @@ module Locations (
|
||||||
gitAnnexJournalDir,
|
gitAnnexJournalDir,
|
||||||
gitAnnexJournalLock,
|
gitAnnexJournalLock,
|
||||||
isLinkToAnnex,
|
isLinkToAnnex,
|
||||||
|
annexHashes,
|
||||||
hashDirMixed,
|
hashDirMixed,
|
||||||
hashDirLower,
|
hashDirLower,
|
||||||
|
|
||||||
|
@ -58,10 +59,18 @@ annexDir = addTrailingPathSeparator "annex"
|
||||||
objectDir :: FilePath
|
objectDir :: FilePath
|
||||||
objectDir = addTrailingPathSeparator $ annexDir </> "objects"
|
objectDir = addTrailingPathSeparator $ annexDir </> "objects"
|
||||||
|
|
||||||
|
{- Two different directory hashes may be used. The mixed case hash
|
||||||
|
- came first, and is fine, except for the problem of case-strict
|
||||||
|
- filesystems such as Linux VFAT (mounted with shortname=mixed),
|
||||||
|
- which do not allow using a directory "XX" when "xx" already exists.
|
||||||
|
- To support that, some repositories will use a lower case hash. -}
|
||||||
|
annexHashes :: [Key -> FilePath]
|
||||||
|
annexHashes = [hashDirMixed, hashDirLower]
|
||||||
|
|
||||||
{- Annexed file's possible locations relative to the .git directory.
|
{- Annexed file's possible locations relative to the .git directory.
|
||||||
- There are two different possibilities, using different hashes. -}
|
- There are two different possibilities, using different hashes. -}
|
||||||
annexLocations :: Key -> [FilePath]
|
annexLocations :: Key -> [FilePath]
|
||||||
annexLocations key = map (annexLocation key) [hashDirMixed, hashDirLower]
|
annexLocations key = map (annexLocation key) annexHashes
|
||||||
annexLocation :: Key -> (Key -> FilePath) -> FilePath
|
annexLocation :: Key -> (Key -> FilePath) -> FilePath
|
||||||
annexLocation key hasher = objectDir </> hasher key </> f </> f
|
annexLocation key hasher = objectDir </> hasher key </> f </> f
|
||||||
where
|
where
|
||||||
|
|
|
@ -62,20 +62,10 @@ directorySetup u c = do
|
||||||
gitConfigSpecialRemote u c' "directory" dir
|
gitConfigSpecialRemote u c' "directory" dir
|
||||||
return $ M.delete "directory" c'
|
return $ M.delete "directory" c'
|
||||||
|
|
||||||
{- Where to store a given Key in the Directory.
|
{- Locations to try to access a given Key in the Directory. -}
|
||||||
-
|
|
||||||
- There are two possible locations to try; this had to be done because
|
|
||||||
- on Linux, vfat filesystem mounted with shortname=mixed have a
|
|
||||||
- variant of case insensativity that causes miserable failure when
|
|
||||||
- hashDirMixed produces eg, "xx" and "XX". The first directory to be
|
|
||||||
- created wins the namespace, and the second one cannot then be created.
|
|
||||||
- But unlike behavior with shortname=lower, "XX/foo" won't look in
|
|
||||||
- "xx/foo".
|
|
||||||
-}
|
|
||||||
locations :: FilePath -> Key -> [FilePath]
|
locations :: FilePath -> Key -> [FilePath]
|
||||||
locations d k = [using hashDirMixed, using hashDirLower]
|
locations d k = map (\h -> d </> h k </> f </> f) annexHashes
|
||||||
where
|
where
|
||||||
using h = d </> h k </> f </> f
|
|
||||||
f = keyFile k
|
f = keyFile k
|
||||||
|
|
||||||
withCheckedFile :: (FilePath -> IO Bool) -> FilePath -> Key -> (FilePath -> IO Bool) -> IO Bool
|
withCheckedFile :: (FilePath -> IO Bool) -> FilePath -> Key -> (FilePath -> IO Bool) -> IO Bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue