use git-annex branch for uuid.log
This commit is contained in:
parent
ae2be332d4
commit
80274f4c92
1 changed files with 5 additions and 11 deletions
16
UUID.hs
16
UUID.hs
|
@ -30,11 +30,10 @@ import qualified Data.Map as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
import qualified Branch
|
||||||
import Types
|
import Types
|
||||||
import Types.UUID
|
import Types.UUID
|
||||||
import Locations
|
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Utility
|
|
||||||
import qualified SysConfig
|
import qualified SysConfig
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
|
@ -103,26 +102,21 @@ describeUUID :: UUID -> String -> Annex ()
|
||||||
describeUUID uuid desc = do
|
describeUUID uuid desc = do
|
||||||
m <- uuidMap
|
m <- uuidMap
|
||||||
let m' = M.insert uuid desc m
|
let m' = M.insert uuid desc m
|
||||||
logfile <- uuidLog
|
Branch.change uuidLog (serialize m')
|
||||||
liftIO $ safeWriteFile logfile (serialize m')
|
|
||||||
where
|
where
|
||||||
serialize m = unlines $ map (\(u, d) -> u++" "++d) $ M.toList m
|
serialize m = unlines $ map (\(u, d) -> u++" "++d) $ M.toList m
|
||||||
|
|
||||||
{- Read and parse the uuidLog into a Map -}
|
{- Read and parse the uuidLog into a Map -}
|
||||||
uuidMap :: Annex (M.Map UUID String)
|
uuidMap :: Annex (M.Map UUID String)
|
||||||
uuidMap = do
|
uuidMap = do
|
||||||
logfile <- uuidLog
|
s <- Branch.get uuidLog
|
||||||
s <- liftIO $ catch (readFile logfile) ignoreerror
|
|
||||||
return $ M.fromList $ map pair $ lines s
|
return $ M.fromList $ map pair $ lines s
|
||||||
where
|
where
|
||||||
pair l =
|
pair l =
|
||||||
if 1 < length (words l)
|
if 1 < length (words l)
|
||||||
then (head $ words l, unwords $ drop 1 $ words l)
|
then (head $ words l, unwords $ drop 1 $ words l)
|
||||||
else ("", "")
|
else ("", "")
|
||||||
ignoreerror _ = return ""
|
|
||||||
|
|
||||||
{- Filename of uuid.log. -}
|
{- Filename of uuid.log. -}
|
||||||
uuidLog :: Annex FilePath
|
uuidLog :: FilePath
|
||||||
uuidLog = do
|
uuidLog = "uuid.log"
|
||||||
g <- Annex.gitRepo
|
|
||||||
return $ gitStateDir g ++ "uuid.log"
|
|
||||||
|
|
Loading…
Reference in a new issue