summaryrefslogtreecommitdiff
path: root/UUID.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 16:15:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 16:15:31 -0400
commit6d13ae10cf1d295b64855984f5a526f8209f3341 (patch)
tree70baa5f95943631e0f0e03a86ef8f57ee5480680 /UUID.hs
parent81d628a8cd6f20c2ef336271ae03376dc75b6920 (diff)
git annex describe
Diffstat (limited to 'UUID.hs')
-rw-r--r--UUID.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/UUID.hs b/UUID.hs
index 8cdee43de..3e6991d48 100644
--- a/UUID.hs
+++ b/UUID.hs
@@ -12,7 +12,8 @@ module UUID (
genUUID,
reposByUUID,
prettyPrintUUIDs,
- describeUUID
+ describeUUID,
+ uuidLog
) where
import Control.Monad.State
@@ -25,6 +26,7 @@ import qualified GitRepo as Git
import Types
import Locations
import qualified Annex
+import Utility
type UUID = String
@@ -110,7 +112,7 @@ describeUUID uuid desc = do
m <- uuidMap
let m' = M.insert uuid desc m
log <- uuidLog
- liftIO $ writeFile log $ serialize m'
+ liftIO $ withFileLocked log WriteMode (\h -> hPutStr h $ serialize m')
where
serialize m = unlines $ map (\(u, d) -> u++" "++d) $ M.toList m
@@ -118,7 +120,9 @@ describeUUID uuid desc = do
uuidMap :: Annex (M.Map UUID String)
uuidMap = do
log <- uuidLog
- s <- liftIO $ catch (readFile log) (\error -> return "")
+ s <- liftIO $ catch
+ (withFileLocked log ReadMode $ \h -> hGetContentsStrict h)
+ (\error -> return "")
return $ M.fromList $ map (\l -> pair l) $ lines s
where
pair l =