diff options
-rw-r--r-- | Locations.hs | 8 | ||||
-rw-r--r-- | Remote/Directory.hs | 24 |
2 files changed, 14 insertions, 18 deletions
diff --git a/Locations.hs b/Locations.hs index 1b5f8108d..2f4a9200d 100644 --- a/Locations.hs +++ b/Locations.hs @@ -21,7 +21,6 @@ module Locations ( gitAnnexJournalDir, gitAnnexJournalLock, isLinkToAnnex, - annexHashes, hashDirMixed, hashDirLower, @@ -80,8 +79,7 @@ gitAnnexLocation key r | Git.repoIsLocalBare r = {- Bare repositories default to hashDirLower for new - content, as it's more portable. -} - go (Git.workTree r) $ - map (annexLocation key) [hashDirLower, hashDirMixed] + go (Git.workTree r) (annexLocations key) | otherwise = {- Non-bare repositories only use hashDirMixed, so - don't need to do any work to check if the file is @@ -189,10 +187,10 @@ prop_idempotent_fileKey s = Just k == fileKey (keyFile k) - 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. -} + - To support that, most repositories use the lower case hash for new data. -} type Hasher = Key -> FilePath annexHashes :: [Hasher] -annexHashes = [hashDirMixed, hashDirLower] +annexHashes = [hashDirLower, hashDirMixed] hashDirMixed :: Hasher hashDirMixed k = addTrailingPathSeparator $ take 2 dir </> drop 2 dir diff --git a/Remote/Directory.hs b/Remote/Directory.hs index 5f294f0be..a6077d813 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -64,7 +64,7 @@ directorySetup u c = do {- Locations to try to access a given Key in the Directory. -} locations :: FilePath -> Key -> [FilePath] -locations d k = map (d </>) (keyLocations k) +locations d k = map (d </>) (keyPaths k) withCheckedFile :: (FilePath -> IO Bool) -> FilePath -> Key -> (FilePath -> IO Bool) -> IO Bool withCheckedFile _ [] _ _ = return False @@ -95,18 +95,16 @@ storeEncrypted d (cipher, enck) k = do return True storeHelper :: FilePath -> Key -> (FilePath -> IO Bool) -> IO Bool -storeHelper d key a = withCheckedFile check d key go - where - check dest = isJust <$> mkdir (parentDir dest) - mkdir = catchMaybeIO . createDirectoryIfMissing True - go dest = do - let dir = parentDir dest - allowWrite dir - ok <- a dest - when ok $ do - preventWrite dest - preventWrite dir - return ok +storeHelper d key a = do + let dest = head $ locations d key + let dir = parentDir dest + createDirectoryIfMissing True dir + allowWrite dir + ok <- a dest + when ok $ do + preventWrite dest + preventWrite dir + return ok retrieve :: FilePath -> Key -> FilePath -> Annex Bool retrieve d k f = liftIO $ withStoredFile d k $ \file -> copyFileExternal file f |