aboutsummaryrefslogtreecommitdiff
path: root/Logs/Trust.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-15 18:11:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-15 18:19:36 -0400
commit95d2391f58ae240e7100f0d5488dd7246f71f3bb (patch)
treef33f21904ae7be4d40b70bab1e2a68fd4eef5526 /Logs/Trust.hs
parentb7e0d39abbc9a09c21c6f0103ad6c9f4547f81fe (diff)
more partial function removal
Left a few Prelude.head's in where it was checked not null and too hard to remove, etc.
Diffstat (limited to 'Logs/Trust.hs')
-rw-r--r--Logs/Trust.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index 196666a84..5d769bd24 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -54,18 +54,16 @@ trustMap = do
Just m -> return m
Nothing -> do
overrides <- M.fromList <$> Annex.getState Annex.forcetrust
- m <- (M.union overrides . simpleMap . parseLog parseTrust) <$>
+ m <- (M.union overrides . simpleMap . parseLog (Just . parseTrust)) <$>
Annex.Branch.get trustLog
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
return m
-parseTrust :: String -> Maybe TrustLevel
-parseTrust s
- | length w > 0 = Just $ parse $ head w
- -- back-compat; the trust.log used to only list trusted repos
- | otherwise = Just Trusted
+{- The trust.log used to only list trusted repos, without a field for the
+ - trust status, which is why this defaults to Trusted. -}
+parseTrust :: String -> TrustLevel
+parseTrust s = maybe Trusted parse $ headMaybe $ words s
where
- w = words s
parse "1" = Trusted
parse "0" = UnTrusted
parse "X" = DeadTrusted
@@ -82,6 +80,6 @@ trustSet :: UUID -> TrustLevel -> Annex ()
trustSet uuid@(UUID _) level = do
ts <- liftIO getPOSIXTime
Annex.Branch.change trustLog $
- showLog showTrust . changeLog ts uuid level . parseLog parseTrust
+ showLog showTrust . changeLog ts uuid level . parseLog (Just . parseTrust)
Annex.changeState $ \s -> s { Annex.trustmap = Nothing }
trustSet NoUUID _ = error "unknown UUID; cannot modify trust level"