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 /Logs/Trust.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 'Logs/Trust.hs')
-rw-r--r-- | Logs/Trust.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Logs/Trust.hs b/Logs/Trust.hs index 53a1bca2c..8c4507dcb 100644 --- a/Logs/Trust.hs +++ b/Logs/Trust.hs @@ -45,18 +45,26 @@ trustMap = do parseTrust :: String -> Maybe TrustLevel parseTrust s - | length w > 0 = readMaybe $ head w + | length w > 0 = Just $ parse $ head w -- back-compat; the trust.log used to only list trusted repos - | otherwise = Just Trusted + | otherwise = Just $ Trusted where w = words s + parse "1" = Trusted + parse "0" = UnTrusted + parse _ = SemiTrusted + +showTrust :: TrustLevel -> String +showTrust SemiTrusted = "?" +showTrust UnTrusted = "0" +showTrust Trusted = "1" {- Changes the trust level for a uuid in the trustLog. -} trustSet :: UUID -> TrustLevel -> Annex () trustSet uuid@(UUID _) level = do ts <- liftIO $ getPOSIXTime Annex.Branch.change trustLog $ - showLog show . changeLog ts uuid level . parseLog parseTrust + showLog showTrust . changeLog ts uuid level . parseLog parseTrust Annex.changeState $ \s -> s { Annex.trustmap = Nothing } trustSet NoUUID _ = error "unknown UUID; cannot modify trust level" |