mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-10-26 21:56:29 +03:00
Set executable permissions once instead of multiple times
This commit is contained in:
parent
48b4891693
commit
408cf093ea
@ -88,7 +88,7 @@ streamStringOutIO
|
|||||||
streamStringOutIO f executable getChunk =
|
streamStringOutIO f executable getChunk =
|
||||||
Exception.Lifted.bracket
|
Exception.Lifted.bracket
|
||||||
(liftIO $ IO.openFile f WriteMode)
|
(liftIO $ IO.openFile f WriteMode)
|
||||||
(liftIO . IO.hClose)
|
(\h -> liftIO (updateExecutablePermissions >> IO.hClose h))
|
||||||
go
|
go
|
||||||
`Exception.Lifted.catch`
|
`Exception.Lifted.catch`
|
||||||
cleanupException
|
cleanupException
|
||||||
@ -100,10 +100,11 @@ streamStringOutIO f executable getChunk =
|
|||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
Just c -> do
|
Just c -> do
|
||||||
liftIO $ Data.ByteString.hPut handle c
|
liftIO $ Data.ByteString.hPut handle c
|
||||||
Control.Monad.when (executable == Executable) $ liftIO $ do
|
|
||||||
p <- Directory.getPermissions f
|
|
||||||
Directory.setPermissions f (p { Directory.executable = True })
|
|
||||||
go handle
|
go handle
|
||||||
|
updateExecutablePermissions =
|
||||||
|
Control.Monad.when (executable == Executable) $ do
|
||||||
|
p <- Directory.getPermissions f
|
||||||
|
Directory.setPermissions f (p { Directory.executable = True })
|
||||||
cleanupException (e :: Exception.Lifted.SomeException) = do
|
cleanupException (e :: Exception.Lifted.SomeException) = do
|
||||||
liftIO $ Directory.removeFile f
|
liftIO $ Directory.removeFile f
|
||||||
Control.Monad.fail $
|
Control.Monad.fail $
|
||||||
|
Loading…
Reference in New Issue
Block a user