avoid using openFile when withFile can be used
Potentially fixes some FD leak if an action on an opened file handle fails for some reason. There have been some hard to reproduce reports of git-annex leaking FDs, and this may solve them.
This commit is contained in:
parent
fd1382f96f
commit
1572c460e8
6 changed files with 14 additions and 28 deletions
|
@ -478,10 +478,9 @@ recordStartTime = do
|
|||
createAnnexDirectory $ parentDir f
|
||||
liftIO $ do
|
||||
nukeFile f
|
||||
h <- openFile f WriteMode
|
||||
t <- modificationTime <$> getFileStatus f
|
||||
hPutStr h $ showTime $ realToFrac t
|
||||
hClose h
|
||||
withFile f WriteMode $ \h -> do
|
||||
t <- modificationTime <$> getFileStatus f
|
||||
hPutStr h $ showTime $ realToFrac t
|
||||
where
|
||||
showTime :: POSIXTime -> String
|
||||
showTime = show
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue