strictness and handle closing
This commit is contained in:
parent
c67521741a
commit
60c672e444
2 changed files with 7 additions and 4 deletions
|
@ -12,7 +12,6 @@
|
||||||
-
|
-
|
||||||
- A line of the log will look like: "date N reponame"
|
- A line of the log will look like: "date N reponame"
|
||||||
- Where N=1 when the repo has the file, and 0 otherwise.
|
- Where N=1 when the repo has the file, and 0 otherwise.
|
||||||
-
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module LocationLog where
|
module LocationLog where
|
||||||
|
@ -69,8 +68,8 @@ readLog file = do
|
||||||
if exists
|
if exists
|
||||||
then do
|
then do
|
||||||
h <- openLocked file ReadMode
|
h <- openLocked file ReadMode
|
||||||
s <- hGetContents h
|
s <- hGetContentsStrict h
|
||||||
-- hClose handle' -- TODO disabled due to lazy IO issue
|
hClose h
|
||||||
-- filter out any unparsable lines
|
-- filter out any unparsable lines
|
||||||
return $ filter (\l -> (status l) /= Undefined )
|
return $ filter (\l -> (status l) /= Undefined )
|
||||||
$ map read $ lines s
|
$ map read $ lines s
|
||||||
|
@ -95,7 +94,7 @@ logNow status repo = do
|
||||||
logFile :: String -> IO String
|
logFile :: String -> IO String
|
||||||
logFile annexedFile = do
|
logFile annexedFile = do
|
||||||
repo <- repoTop
|
repo <- repoTop
|
||||||
return $ repo ++ "/.git-annex/" ++
|
return $ (gitStateDir repo) ++
|
||||||
(gitRelative repo annexedFile) ++ ".log"
|
(gitRelative repo annexedFile) ++ ".log"
|
||||||
|
|
||||||
{- Returns a list of repositories that, according to the log, have
|
{- Returns a list of repositories that, according to the log, have
|
||||||
|
|
|
@ -19,6 +19,10 @@ openLocked file mode = do
|
||||||
lockType ReadMode = ReadLock
|
lockType ReadMode = ReadLock
|
||||||
lockType _ = WriteLock
|
lockType _ = WriteLock
|
||||||
|
|
||||||
|
{- A version of hgetContents that is not lazy. Ensures file is
|
||||||
|
- all read before it gets closed. -}
|
||||||
|
hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s
|
||||||
|
|
||||||
{- Returns the parent directory of a path. Parent of / is "" -}
|
{- Returns the parent directory of a path. Parent of / is "" -}
|
||||||
parentDir :: String -> String
|
parentDir :: String -> String
|
||||||
parentDir dir =
|
parentDir dir =
|
||||||
|
|
Loading…
Add table
Reference in a new issue