diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-07 23:21:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-08 00:17:54 -0400 |
commit | b11a63a860e8446cf3a4b35a5d8ef76329d5135c (patch) | |
tree | c8ae0c94d6473a3ccc7b15bdbc72d5b5c6ae96b3 /Annex/UUID.hs | |
parent | fdf988be6d2b3bb931a9eb3dcf3fbb83b1fb8c17 (diff) |
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.
Diffstat (limited to 'Annex/UUID.hs')
-rw-r--r-- | Annex/UUID.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Annex/UUID.hs b/Annex/UUID.hs index 90189bc47..d3d674dcc 100644 --- a/Annex/UUID.hs +++ b/Annex/UUID.hs @@ -30,7 +30,7 @@ configkey = "annex.uuid" {- Generates a UUID. There is a library for this, but it's not packaged, - so use the command line tool. -} genUUID :: IO UUID -genUUID = pOpen ReadFromPipe command params $ liftM read . hGetLine +genUUID = pOpen ReadFromPipe command params $ liftM toUUID . hGetLine where command = SysConfig.uuid params = if command == "uuid" @@ -56,12 +56,12 @@ getRepoUUID r = do return u else return c where - cached g = read $ Git.configGet g cachekey "" + cached g = toUUID $ Git.configGet g cachekey "" updatecache g u = when (g /= r) $ storeUUID cachekey u cachekey = "remote." ++ fromMaybe "" (Git.repoRemoteName r) ++ ".annex-uuid" getUncachedUUID :: Git.Repo -> UUID -getUncachedUUID r = read $ Git.configGet r configkey "" +getUncachedUUID r = toUUID $ Git.configGet r configkey "" {- Make sure that the repo has an annex.uuid setting. -} prepUUID :: Annex () @@ -69,4 +69,4 @@ prepUUID = whenM ((==) NoUUID <$> getUUID) $ storeUUID configkey =<< liftIO genUUID storeUUID :: String -> UUID -> Annex () -storeUUID configfield uuid = setConfig configfield (show uuid) +storeUUID configfield = setConfig configfield . fromUUID |