From d0287786f1cfe0ca7871db188ec7b4a985ef2336 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sun, 14 Oct 2018 18:02:04 +0200 Subject: [PATCH] Remove usage of addCleanup --- src/GDAL/Internal/Layer.chs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/GDAL/Internal/Layer.chs b/src/GDAL/Internal/Layer.chs index e435b47..b246323 100644 --- a/src/GDAL/Internal/Layer.chs +++ b/src/GDAL/Internal/Layer.chs @@ -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 @@ -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