summaryrefslogtreecommitdiff
path: root/UUID.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-14 14:22:05 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-14 14:22:05 -0400
commit65e4f9cc73f4800fd4dcb5503f7a428539e1e959 (patch)
tree227cc7a3a6a4e284eaa62592e2827ceb75c68dad /UUID.hs
parenta200761e66f01a271c90ce67482105befca6ef09 (diff)
update cached uuids if it's noticed they changed
Diffstat (limited to 'UUID.hs')
-rw-r--r--UUID.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/UUID.hs b/UUID.hs
index c77004527..9348c7b43 100644
--- a/UUID.hs
+++ b/UUID.hs
@@ -41,22 +41,21 @@ genUUID = liftIO $ pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
getUUID :: Git.Repo -> Annex UUID
getUUID r = do
g <- Annex.gitRepo
- let uuid = cached r g
- if (uuid /= "")
- then return $ uuid
- else do
- let uuid = uncached r
- if (uuid /= "")
- then do
- updatecache r g uuid
- return uuid
- else return ""
+
+ let c = cached r g
+ let u = uncached r
+
+ if (c /= u && u /= "")
+ then do
+ updatecache g r u
+ return u
+ else return c
where
uncached r = Git.configGet r "annex.uuid" ""
cached r g = Git.configGet g (cachekey r) ""
- updatecache r g uuid = do
- if (g /= r)
- then setConfig (cachekey r) uuid
+ updatecache g r u = do
+ if (g /= r)
+ then setConfig (cachekey r) u
else return ()
cachekey r = "remote." ++ (Git.repoRemoteName r) ++ ".annex-uuid"