From 8a4fe46a9820bb6987bf55adc9b6c0e12c6bf9c7 Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Thu, 25 Apr 2024 15:25:56 +0200 Subject: [PATCH] Passing resource to the subsequent conduit correctly --- conduit-extra/Data/Conduit/Binary.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conduit-extra/Data/Conduit/Binary.hs b/conduit-extra/Data/Conduit/Binary.hs index 574b2c141..6bfa19788 100644 --- a/conduit-extra/Data/Conduit/Binary.hs +++ b/conduit-extra/Data/Conduit/Binary.hs @@ -321,7 +321,8 @@ sinkCacheLength = do (\(fp, h) -> IO.hClose h `finally` removeFile fp) len <- sinkHandleLen h liftIO $ IO.hClose h - return (len, CC.sourceFile fp >> release releaseKey) + cleanup <- fromMaybe (pure ()) <$> unprotect releaseKey + return (len, CC.sourceFile fp >> void (register cleanup)) where sinkHandleLen :: MonadResource m => IO.Handle -> ConduitT S.ByteString o m Word64 sinkHandleLen h =