implement 3 level trust storage in trust.log

This commit is contained in:
Joey Hess 2011-01-26 15:37:16 -04:00
parent f7e3d6eea2
commit 268cb35e64
9 changed files with 153 additions and 65 deletions

30
UUID.hs
View file

@ -17,10 +17,7 @@ module UUID (
reposWithoutUUID,
prettyPrintUUIDs,
describeUUID,
uuidLog,
trustLog,
getTrusted,
setTrusted
uuidLog
) where
import Control.Monad.State
@ -141,28 +138,3 @@ uuidLog :: Annex FilePath
uuidLog = do
g <- Annex.gitRepo
return $ gitStateDir g ++ "uuid.log"
{- Filename of trust.log. -}
trustLog :: Annex FilePath
trustLog = do
g <- Annex.gitRepo
return $ gitStateDir g ++ "trust.log"
{- List of trusted UUIDs. -}
getTrusted :: Annex [UUID]
getTrusted = do
logfile <- trustLog
s <- liftIO $ catch (readFile logfile) ignoreerror
return $ parse s
where
parse [] = []
parse s = map firstword $ lines s
firstword [] = ""
firstword l = head $ words l
ignoreerror _ = return ""
{- Changes the list of trusted UUIDs. -}
setTrusted :: [UUID] -> Annex ()
setTrusted u = do
logfile <- trustLog
liftIO $ safeWriteFile logfile $ unlines u