summaryrefslogtreecommitdiff
path: root/Annex
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 /Annex
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 'Annex')
-rw-r--r--Annex/Locations.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Annex/Locations.hs b/Annex/Locations.hs
index e12920091..47768b9c1 100644
--- a/Annex/Locations.hs
+++ b/Annex/Locations.hs
@@ -69,6 +69,7 @@ module Annex.Locations (
hashDirMixed,
hashDirLower,
preSanitizeKeyName,
+ reSanitizeKeyName,
prop_isomorphic_fileKey
) where
@@ -426,7 +427,10 @@ gitAnnexAssistantDefaultDir = "annex"
- same key.
-}
preSanitizeKeyName :: String -> String
-preSanitizeKeyName = concatMap escape
+preSanitizeKeyName = preSanitizeKeyName' False
+
+preSanitizeKeyName' :: Bool -> String -> String
+preSanitizeKeyName' resanitize = concatMap escape
where
escape c
| isAsciiUpper c || isAsciiLower c || isDigit c = [c]
@@ -435,9 +439,16 @@ preSanitizeKeyName = concatMap escape
-- , is safe and uncommon, so will be used to escape
-- other characters. By itself, it is escaped to
-- doubled form.
- | c == ',' = ",,"
+ | c == ',' = if not resanitize
+ then ",,"
+ else ","
| otherwise = ',' : show (ord c)
+{- Converts a keyName that has been santizied with an old version of
+ - preSanitizeKeyName to be sanitized with the new version. -}
+reSanitizeKeyName :: String -> String
+reSanitizeKeyName = preSanitizeKeyName' True
+
{- Converts a key into a filename fragment without any directory.
-
- Escape "/" in the key name, to keep a flat tree of files and avoid