diff --git a/Annex/Locations.hs b/Annex/Locations.hs index cceeff77c8..a407be740e 100644 --- a/Annex/Locations.hs +++ b/Annex/Locations.hs @@ -551,7 +551,7 @@ gitAnnexAssistantDefaultDir = "annex" {- Sanitizes a String that will be used as part of a Key's keyName, - dealing with characters that cause problems. - - - This is used when a new Key is initially being generated, eg by getKey. + - This is used when a new Key is initially being generated, eg by genKey. - Unlike keyFile and fileKey, it does not need to be a reversable - escaping. Also, it's ok to change this to add more problematic - characters later. Unlike changing keyFile, which could result in the diff --git a/Backend.hs b/Backend.hs index b2c40a53ac..99f4c296fd 100644 --- a/Backend.hs +++ b/Backend.hs @@ -56,7 +56,7 @@ defaultBackend = maybe cache return =<< Annex.getState Annex.backend genKey :: KeySource -> MeterUpdate -> Maybe Backend -> Annex (Key, Backend) genKey source meterupdate preferredbackend = do b <- maybe defaultBackend return preferredbackend - case B.getKey b of + case B.genKey b of Just a -> do k <- a source meterupdate return (makesane k, b) diff --git a/Backend/Hash.hs b/Backend/Hash.hs index d6714c703b..2b8bcd78d3 100644 --- a/Backend/Hash.hs +++ b/Backend/Hash.hs @@ -74,7 +74,7 @@ backends = concatMap (\h -> [genBackendE h, genBackend h]) hashes genBackend :: Hash -> Backend genBackend hash = Backend { backendVariety = hashKeyVariety hash (HasExt False) - , getKey = Just (keyValue hash) + , genKey = Just (keyValue hash) , verifyKeyContent = Just $ checkKeyChecksum hash , canUpgradeKey = Just needsUpgrade , fastMigrate = Just trivialMigrate @@ -85,7 +85,7 @@ genBackend hash = Backend genBackendE :: Hash -> Backend genBackendE hash = (genBackend hash) { backendVariety = hashKeyVariety hash (HasExt True) - , getKey = Just (keyValueE hash) + , genKey = Just (keyValueE hash) } hashKeyVariety :: Hash -> HasExt -> KeyVariety @@ -308,10 +308,10 @@ md5Hasher = show . md5 testKeyBackend :: Backend testKeyBackend = let b = genBackendE (SHA2Hash (HashSize 256)) - gk = case getKey b of + gk = case genKey b of Nothing -> Nothing Just f -> Just (\ks p -> addE <$> f ks p) - in b { getKey = gk } + in b { genKey = gk } where addE k = alterKey k $ \d -> d { keyName = keyName d <> longext diff --git a/Backend/URL.hs b/Backend/URL.hs index 2d0b7bc923..5c8235760a 100644 --- a/Backend/URL.hs +++ b/Backend/URL.hs @@ -21,7 +21,7 @@ backends = [backend] backend :: Backend backend = Backend { backendVariety = URLKey - , getKey = Nothing + , genKey = Nothing , verifyKeyContent = Nothing , canUpgradeKey = Nothing , fastMigrate = Nothing diff --git a/Backend/WORM.hs b/Backend/WORM.hs index e2b38efb55..bf7dc7bf63 100644 --- a/Backend/WORM.hs +++ b/Backend/WORM.hs @@ -24,7 +24,7 @@ backends = [backend] backend :: Backend backend = Backend { backendVariety = WORMKey - , getKey = Just keyValue + , genKey = Just keyValue , verifyKeyContent = Nothing , canUpgradeKey = Just needsUpgrade , fastMigrate = Just removeProblemChars diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs index 19a522ba65..5725952eb8 100644 --- a/Command/TestRemote.hs +++ b/Command/TestRemote.hs @@ -13,7 +13,7 @@ import Command import qualified Annex import qualified Remote import qualified Types.Remote as Remote -import qualified Types.Backend as Backend +import qualified Types.Backend import Types.KeySource import Annex.Content import Annex.WorkTree @@ -290,7 +290,7 @@ test runannex mkr mkk = present r k b = (== Right b) <$> Remote.hasKey r k fsck _ k = case maybeLookupBackendVariety (fromKey keyVariety k) of Nothing -> return True - Just b -> case Backend.verifyKeyContent b of + Just b -> case Types.Backend.verifyKeyContent b of Nothing -> return True Just verifier -> verifier k (serializeKey k) get r k = getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k $ \dest -> @@ -432,7 +432,7 @@ randKey sz = withTmpFile "randkey" $ \f h -> do , contentLocation = toRawFilePath f , inodeCache = Nothing } - k <- case Backend.getKey Backend.Hash.testKeyBackend of + k <- case Types.Backend.genKey Backend.Hash.testKeyBackend of Just a -> a ks nullMeterUpdate Nothing -> giveup "failed to generate random key (backend problem)" _ <- moveAnnex k f diff --git a/Test/Framework.hs b/Test/Framework.hs index ca4d009a5c..2e5584eefd 100644 --- a/Test/Framework.hs +++ b/Test/Framework.hs @@ -584,7 +584,7 @@ backend_ :: String -> Types.Backend backend_ = Backend.lookupBackendVariety . Types.Key.parseKeyVariety . encodeBS getKey :: Types.Backend -> FilePath -> IO Types.Key -getKey b f = case Types.Backend.getKey b of +getKey b f = case Types.Backend.genKey b of Just a -> annexeval $ a ks Utility.Metered.nullMeterUpdate Nothing -> error "internal" where diff --git a/Types/Backend.hs b/Types/Backend.hs index 5726410f6f..d10f5c96d6 100644 --- a/Types/Backend.hs +++ b/Types/Backend.hs @@ -17,7 +17,7 @@ import Utility.FileSystemEncoding data BackendA a = Backend { backendVariety :: KeyVariety - , getKey :: Maybe (KeySource -> MeterUpdate -> a Key) + , genKey :: Maybe (KeySource -> MeterUpdate -> a Key) -- Verifies the content of a key using a hash. This does not need -- to be cryptographically secure. , verifyKeyContent :: Maybe (Key -> FilePath -> a Bool)