This commit is contained in:
Joey Hess 2025-02-27 16:17:42 -04:00
parent e6ae5e8d56
commit d2091730e9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 36 additions and 31 deletions

View file

@ -10,10 +10,8 @@ module Backend.VURL.Utilities where
import Annex.Common
import Types.Key
import Types.Backend
import Types.KeySource
import Logs.EquivilantKeys
import qualified Backend.Hash
import Utility.Metered
migrateFromURLToVURL :: Key -> Backend -> AssociatedFile -> Bool -> Annex (Maybe Key)
migrateFromURLToVURL oldkey newbackend _af inannex
@ -41,26 +39,3 @@ migrateFromVURLToURL oldkey newbackend _af _
(keyData oldkey)
{ keyVariety = URLKey }
| otherwise = return Nothing
-- The Backend must use a cryptographically secure hash.
generateEquivilantKey :: Backend -> OsPath -> Annex (Maybe Key)
generateEquivilantKey b f =
case genKey b of
Just genkey -> do
showSideAction (UnquotedString Backend.Hash.descChecksum)
Just <$> genkey source nullMeterUpdate
Nothing -> return Nothing
where
source = KeySource
{ keyFilename = mempty -- avoid adding any extension
, contentLocation = f
, inodeCache = Nothing
}
recordVurlKey :: Backend -> OsPath -> Key -> [Key] -> Annex Bool
recordVurlKey b f key eks = generateEquivilantKey b f >>= \case
Nothing -> return False
Just ek -> do
unless (ek `elem` eks) $
setEquivilantKey key ek
return True