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:
Joey Hess 2014-02-03 10:16:05 -04:00
parent fd1382f96f
commit 1572c460e8
6 changed files with 14 additions and 28 deletions

View file

@ -145,9 +145,8 @@ storeEncrypted r buprepo (cipher, enck) k _p =
retrieve :: BupRepo -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
retrieve buprepo k _f d _p = do
let params = bupParams "join" buprepo [Param $ bupRef k]
liftIO $ catchBoolIO $ do
tofile <- openFile d WriteMode
pipeBup params Nothing (Just tofile)
liftIO $ catchBoolIO $ withFIle d WriteMode $
pipeBup params Nothing . Just
retrieveCheap :: BupRepo -> Key -> FilePath -> Annex Bool
retrieveCheap _ _ _ = return False