summaryrefslogtreecommitdiff
path: root/Annex/UUID.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-08 15:34:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-08 16:27:20 -0400
commitbf460a0a98d7e4c7f4eac525fcf300629db582b6 (patch)
treebff7cd09529c40fa8cb76fd92428cc41e24ad808 /Annex/UUID.hs
parent2ff8915365099501382183af9855e739fc234861 (diff)
reorder repo parameters last
Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators.
Diffstat (limited to 'Annex/UUID.hs')
-rw-r--r--Annex/UUID.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Annex/UUID.hs b/Annex/UUID.hs
index d3d674dcc..6fc04c0f0 100644
--- a/Annex/UUID.hs
+++ b/Annex/UUID.hs
@@ -45,23 +45,23 @@ getUUID = getRepoUUID =<< gitRepo
{- Looks up a repo's UUID. May return "" if none is known. -}
getRepoUUID :: Git.Repo -> Annex UUID
getRepoUUID r = do
- g <- gitRepo
-
- let c = cached g
+ c <- fromRepo cached
let u = getUncachedUUID r
if c /= u && u /= NoUUID
then do
- updatecache g u
+ updatecache u
return u
else return c
where
- cached g = toUUID $ Git.configGet g cachekey ""
- updatecache g u = when (g /= r) $ storeUUID cachekey u
+ cached g = toUUID $ Git.configGet cachekey "" g
+ updatecache u = do
+ g <- gitRepo
+ when (g /= r) $ storeUUID cachekey u
cachekey = "remote." ++ fromMaybe "" (Git.repoRemoteName r) ++ ".annex-uuid"
getUncachedUUID :: Git.Repo -> UUID
-getUncachedUUID r = toUUID $ Git.configGet r configkey ""
+getUncachedUUID = toUUID . Git.configGet configkey ""
{- Make sure that the repo has an annex.uuid setting. -}
prepUUID :: Annex ()