summaryrefslogtreecommitdiff
path: root/Trust.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-22 17:08:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-22 17:08:51 -0400
commit4c4ebf2d7570030a70fdbd313b8b60e9fa727eee (patch)
tree06c632c16399245182f38f3d42b5c46d1d7a71c7 /Trust.hs
parent235e2e63a13c629dcca1aa1638f5f47a8d3983ba (diff)
store trust.log and remote.log in the git-annex branch
.. and I think that's everything that will use the branch
Diffstat (limited to 'Trust.hs')
-rw-r--r--Trust.hs27
1 files changed, 6 insertions, 21 deletions
diff --git a/Trust.hs b/Trust.hs
index aaca3b370..d328235bf 100644
--- a/Trust.hs
+++ b/Trust.hs
@@ -18,18 +18,14 @@ import Control.Monad.State
import qualified Data.Map as M
import TrustLevel
-import qualified GitRepo as Git
+import qualified Branch
import Types
import UUID
-import Locations
import qualified Annex
-import Utility
{- Filename of trust.log. -}
-trustLog :: Annex FilePath
-trustLog = do
- g <- Annex.gitRepo
- return $ gitStateDir g ++ "trust.log"
+trustLog :: FilePath
+trustLog = "trust.log"
{- Returns a list of UUIDs at the specified trust level. -}
trustGet :: TrustLevel -> Annex [UUID]
@@ -41,12 +37,9 @@ trustGet level = do
- values from forcetrust -}
trustMap :: Annex (M.Map UUID TrustLevel)
trustMap = do
- logfile <- trustLog
overrides <- Annex.getState Annex.forcetrust
- s <- liftIO $ catch (readFile logfile) ignoreerror
+ s <- Branch.get trustLog
return $ M.fromList $ trustMapParse s ++ overrides
- where
- ignoreerror _ = return ""
{- Trust map parser. -}
trustMapParse :: String -> [(UUID, TrustLevel)]
@@ -60,7 +53,7 @@ trustMapParse s = map pair $ filter (not . null) $ lines s
where
w = words l
-{- Changes the trust level for a uuid in the trustLog, and commits it. -}
+{- Changes the trust level for a uuid in the trustLog. -}
trustSet :: UUID -> TrustLevel -> Annex ()
trustSet uuid level = do
when (null uuid) $
@@ -68,15 +61,7 @@ trustSet uuid level = do
m <- trustMap
when (M.lookup uuid m /= Just level) $ do
let m' = M.insert uuid level m
- logfile <- trustLog
- liftIO $ safeWriteFile logfile (serialize m')
- g <- Annex.gitRepo
- liftIO $ Git.run g "add" [File logfile]
- liftIO $ Git.run g "commit"
- [ Params "-q -m"
- , Param "git annex trust change"
- , File logfile
- ]
+ Branch.change trustLog (serialize m')
where
serialize m = unlines $ map showpair $ M.toList m
showpair (u, t) = u ++ " " ++ show t