Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of addCleanup #17

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/GDAL/Internal/Layer.chs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module GDAL.Internal.Layer (
import Data.ByteString.Unsafe (unsafeUseAsCString)
import Data.Coerce (coerce)
import Data.Conduit ( Conduit, Sink, Source
, addCleanup, awaitForever, yield
, awaitForever, yield
, bracketP, catchC
, (=$=))
import qualified Data.Conduit.List as CL
Expand Down Expand Up @@ -377,9 +377,12 @@ instance HasLayerTransaction ReadWrite where
bracketP (alloc' state) free $ \ seed@(layer,_) -> do
liftIO $ checkOGRError "StartTransaction" $
{#call OGR_L_StartTransaction as ^#} (unLayer layer)
addCleanup (\terminated -> when terminated (commit layer)) $

res <-
inside seed `catchC`
\(e :: SomeException) -> rollback layer >> throwM e
commit layer
pure res
where
alloc' = runWithInternalState alloc
free = closeLayer . fst
Expand Down