summaryrefslogtreecommitdiff
path: root/Backend/WORM.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-08-17 15:09:38 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-08-17 15:09:38 -0400
commit33e8fbefb92546ca94e98ddd68b9f74f0b38d140 (patch)
tree713dcb658f2c431ac2062d3b9ccd16a5250e1b4d /Backend/WORM.hs
parentdbd6f8c1425e1d928d7fcf53f53357c4e51179fb (diff)
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.
Diffstat (limited to 'Backend/WORM.hs')
-rw-r--r--Backend/WORM.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/Backend/WORM.hs b/Backend/WORM.hs
index d7220a431..678784fdf 100644
--- a/Backend/WORM.hs
+++ b/Backend/WORM.hs
@@ -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