e7652b0997
This needs the content to be present in order to hash it. But it's not possible for a module used by Backend.URL to call inAnnex because that would entail a dependency loop. So instead, rely on the fact that Command.Migrate calls inAnnex before performing a migration. But, Command.ExamineKey calls fastMigrate and the key may or may not exist, and it's not wanting to actually perform a migration in any case. To handle that, had to add an additional value to fastMigrate to indicate whether the content is inAnnex. Factored generateEquivilantKey out of Remote.Web. Note that migrateFromURLToVURL hardcodes use of the SHA256E backend. It would have been difficult not to, given all the dependency loop issues. But --backend and annex.backend are used to tell git-annex migrate to use VURL in any case, so there's no config knob that the user could expect to configure that. Sponsored-by: Brock Spratlen on Patreon
39 lines
1.1 KiB
Haskell
39 lines
1.1 KiB
Haskell
{- git-annex backend varieties
|
|
-
|
|
- Copyright 2012-2024 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Backend.Variety where
|
|
|
|
import qualified Data.Map as M
|
|
|
|
import Annex.Common
|
|
import Types.Key
|
|
import Types.Backend
|
|
import qualified Backend.External
|
|
|
|
-- When adding a new backend, import it here and add it to the builtinList.
|
|
import qualified Backend.Hash
|
|
import qualified Backend.WORM
|
|
import qualified Backend.URL
|
|
|
|
{- Regular backends. Does not include externals or VURL. -}
|
|
regularBackendList :: [Backend]
|
|
regularBackendList = Backend.Hash.backends
|
|
++ Backend.WORM.backends
|
|
++ Backend.URL.backends
|
|
|
|
{- The default hashing backend. -}
|
|
defaultHashBackend :: Backend
|
|
defaultHashBackend = Prelude.head regularBackendList
|
|
|
|
makeVarietyMap :: [Backend] -> M.Map KeyVariety Backend
|
|
makeVarietyMap l = M.fromList $ zip (map backendVariety l) l
|
|
|
|
maybeLookupBackendVarietyMap :: KeyVariety -> M.Map KeyVariety Backend -> Annex (Maybe Backend)
|
|
maybeLookupBackendVarietyMap (ExternalKey s hasext) _varitymap =
|
|
Just <$> Backend.External.makeBackend s hasext
|
|
maybeLookupBackendVarietyMap v varietymap =
|
|
pure $ M.lookup v varietymap
|