more efficient encoding

This commit is contained in:
Joey Hess 2018-08-31 13:49:08 -04:00
parent 24b76cb8e0
commit 53d839d543
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -759,14 +759,15 @@ mkS3VersionID' o (Just s)
| otherwise = Nothing
mkS3VersionID' _ Nothing = Nothing
-- A S3 version ID is "url ready" so does not contain spaces,
-- but an Object may contain spaces, so put it last.
-- A S3 version ID is "url ready" so does not contain '#' and so we'll use
-- that to separate it from the object id. (Could use a space, but spaces
-- in metadata values lead to an inefficient encoding.)
formatS3VersionID :: S3VersionID -> String
formatS3VersionID (S3VersionID o v) = v ++ ' ' : T.unpack o
formatS3VersionID (S3VersionID o v) = v ++ '#' : T.unpack o
parseS3VersionID :: String -> Maybe S3VersionID
parseS3VersionID s =
let (v, o) = separate (== ' ') s
let (v, o) = separate (== '#') s
in mkS3VersionID' (T.pack o) (Just v)
setS3VersionID :: S3Info -> UUID -> Key -> Maybe S3VersionID -> Annex ()