implement 3 level trust storage in trust.log
This commit is contained in:
parent
f7e3d6eea2
commit
268cb35e64
9 changed files with 153 additions and 65 deletions
30
UUID.hs
30
UUID.hs
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue