From b11a63a860e8446cf3a4b35a5d8ef76329d5135c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Nov 2011 23:21:22 -0400 Subject: clean up read/show abuse Avoid ever using read to parse a non-haskell formatted input string. show :: Key is arguably still show abuse, but displaying Keys as filenames is just too useful to give up. --- Remote/Bup.hs | 10 ++++++---- Remote/Helper/Special.hs | 2 +- Remote/S3real.hs | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'Remote') diff --git a/Remote/Bup.hs b/Remote/Bup.hs index b613225b8..3e621ce56 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -161,13 +161,15 @@ storeBupUUID u buprepo = do then do showAction "storing uuid" onBupRemote r boolSystem "git" - [Params $ "config annex.uuid " ++ show u] + [Params $ "config annex.uuid " ++ v] >>! error "ssh failed" else liftIO $ do r' <- Git.configRead r let olduuid = Git.configGet r' "annex.uuid" "" - when (olduuid == "") $ - Git.run r' "config" [Param "annex.uuid", Param $ show u] + when (olduuid == "") $ Git.run r' "config" + [Param "annex.uuid", Param v] + where + v = fromUUID u onBupRemote :: Git.Repo -> (FilePath -> [CommandParam] -> IO a) -> FilePath -> [CommandParam] -> Annex a onBupRemote r a command params = do @@ -192,7 +194,7 @@ getBupUUID r u | otherwise = liftIO $ do ret <- try $ Git.configRead r case ret of - Right r' -> return (read $ Git.configGet r' "annex.uuid" "", r') + Right r' -> return (toUUID $ Git.configGet r' "annex.uuid" "", r') Left _ -> return (NoUUID, r) {- Converts a bup remote path spec into a Git.Repo. There are some diff --git a/Remote/Helper/Special.hs b/Remote/Helper/Special.hs index 8a9a01a22..38f24eb37 100644 --- a/Remote/Helper/Special.hs +++ b/Remote/Helper/Special.hs @@ -32,7 +32,7 @@ gitConfigSpecialRemote u c k v = do g <- gitRepo liftIO $ do Git.run g "config" [Param (configsetting $ "annex-"++k), Param v] - Git.run g "config" [Param (configsetting "annex-uuid"), Param $ show u] + Git.run g "config" [Param (configsetting "annex-uuid"), Param $ fromUUID u] where remotename = fromJust (M.lookup "name" c) configsetting s = "remote." ++ remotename ++ "." ++ s diff --git a/Remote/S3real.hs b/Remote/S3real.hs index 1f5b2bd59..1281c2786 100644 --- a/Remote/S3real.hs +++ b/Remote/S3real.hs @@ -64,7 +64,7 @@ s3Setup :: UUID -> RemoteConfig -> Annex RemoteConfig s3Setup u c = handlehost $ M.lookup "host" c where remotename = fromJust (M.lookup "name" c) - defbucket = remotename ++ "-" ++ show u + defbucket = remotename ++ "-" ++ fromUUID u defaults = M.fromList [ ("datacenter", "US") , ("storageclass", "STANDARD") -- cgit v1.2.3