use lowercase hash by default; non-bare repos are a special case

Directory special remotes will now always store keys in the lowercase name,
which avoids the complication of catching failures to create the mixed case
name.

Git remotes using http will now try the lowercase name first.
This commit is contained in:
Joey Hess 2011-12-02 14:56:48 -04:00
parent 0815cc2fc1
commit db5b479f3f
2 changed files with 14 additions and 18 deletions

View file

@ -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