diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-16 16:15:31 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-16 16:15:31 -0400 |
commit | 6d13ae10cf1d295b64855984f5a526f8209f3341 (patch) | |
tree | 70baa5f95943631e0f0e03a86ef8f57ee5480680 /UUID.hs | |
parent | 81d628a8cd6f20c2ef336271ae03376dc75b6920 (diff) |
git annex describe
Diffstat (limited to 'UUID.hs')
-rw-r--r-- | UUID.hs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 = |