migrate: WORM keys containing spaces will be migrated to not contain spaces anymore
To work around the problem that the external special remote protocol does not support keys containing spaces. This commit was sponsored by Denis Dzyubenko on Patreon.
This commit is contained in:
parent
51801cff6a
commit
96c055eda2
3 changed files with 31 additions and 4 deletions
|
@ -22,8 +22,8 @@ backend = Backend
|
|||
{ backendVariety = WORMKey
|
||||
, getKey = keyValue
|
||||
, verifyKeyContent = Nothing
|
||||
, canUpgradeKey = Nothing
|
||||
, fastMigrate = Nothing
|
||||
, canUpgradeKey = Just needsUpgrade
|
||||
, fastMigrate = Just removeSpaces
|
||||
, isStableKey = const True
|
||||
}
|
||||
|
||||
|
@ -42,3 +42,17 @@ keyValue source = do
|
|||
, keySize = Just sz
|
||||
, keyMtime = Just $ modificationTime stat
|
||||
}
|
||||
|
||||
{- Old WORM keys could contain spaces, and can be upgraded to remove them. -}
|
||||
needsUpgrade :: Key -> Bool
|
||||
needsUpgrade key = ' ' `elem` keyName key
|
||||
|
||||
removeSpaces :: Key -> Backend -> AssociatedFile -> Maybe Key
|
||||
removeSpaces oldkey newbackend _
|
||||
| migratable = Just $ oldkey
|
||||
{ keyName = reSanitizeKeyName (keyName oldkey) }
|
||||
| otherwise = Nothing
|
||||
where
|
||||
migratable = oldvariety == newvariety
|
||||
oldvariety = keyVariety oldkey
|
||||
newvariety = backendVariety newbackend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue