This commit is contained in:
Joey Hess 2011-11-19 15:40:40 -04:00
parent 32d9813b1d
commit 0fa1d136dc

View file

@ -39,10 +39,11 @@ genUUID = pOpen ReadFromPipe command params $ liftM toUUID . hGetLine
-- uuidgen generates random uuid by default -- uuidgen generates random uuid by default
else [] else []
{- Get current repository's UUID. -}
getUUID :: Annex UUID getUUID :: Annex UUID
getUUID = getRepoUUID =<< gitRepo getUUID = getRepoUUID =<< gitRepo
{- Looks up a repo's UUID. May return "" if none is known. -} {- Looks up a repo's UUID, caching it in .git/config if it's not already. -}
getRepoUUID :: Git.Repo -> Annex UUID getRepoUUID :: Git.Repo -> Annex UUID
getRepoUUID r = do getRepoUUID r = do
c <- fromRepo cached c <- fromRepo cached
@ -54,7 +55,7 @@ getRepoUUID r = do
return u return u
else return c else return c
where where
cached g = toUUID $ Git.configGet cachekey "" g cached = toUUID . Git.configGet cachekey ""
updatecache u = do updatecache u = do
g <- gitRepo g <- gitRepo
when (g /= r) $ storeUUID cachekey u when (g /= r) $ storeUUID cachekey u