rename key2file and file2key

What these generate is not really suitable to be used as a filename,
which is why keyFile and fileKey further escape it. These are just
serializing Keys.

Also removed a quickcheck test that was very unlikely to test anything
useful, since it relied on random chance creating something that looks
like a serialized key. The other test is sufficient for testing what
that was intended to test anyway.
This commit is contained in:
Joey Hess 2019-01-14 13:03:35 -04:00
parent ff0a2bee2d
commit d3ab5e626b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
40 changed files with 97 additions and 108 deletions

View file

@ -506,7 +506,7 @@ reSanitizeKeyName = preSanitizeKeyName' True
- can cause existing objects to get lost.
-}
keyFile :: Key -> FilePath
keyFile = concatMap esc . key2file
keyFile = concatMap esc . serializeKey
where
esc '&' = "&a"
esc '%' = "&s"
@ -517,7 +517,7 @@ keyFile = concatMap esc . key2file
{- Reverses keyFile, converting a filename fragment (ie, the basename of
- the symlink target) into a key. -}
fileKey :: FilePath -> Maybe Key
fileKey = file2key . unesc []
fileKey = deserializeKey . unesc []
where
unesc r [] = reverse r
unesc r ('%':cs) = unesc ('/':r) cs