@@ -59,10 +59,12 @@ import Data.List (sortBy)
5959import Data.Function (on, fix)
6060import System.Directory (removeFile, getTemporaryDirectory)
6161import System.IO (hClose, openBinaryTempFile)
62+import System.IO.Error (isDoesNotExistError)
6263import Network.Wai
6364import qualified Network.HTTP.Types as H
6465import Control.Applicative ((<$>))
65−import Control.Monad (when, unless)
66+import Control.Exception (catchJust)
67+import Control.Monad (when, unless, guard)
6668import Control.Monad.Trans.Resource (allocate, release, register, InternalState, runInternalState)
6769import Data.IORef
6870import Network.HTTP.Types (hContentType)
@@ -128,7 +130,7 @@ tempFileBackEndOpts :: IO FilePath -- ^ get temporary directory
128130 -> IO FilePath
129131tempFileBackEndOpts getTmpDir pattrn internalState _ _ popper = do
130132 (key, (fp, h)) <- flip runInternalState internalState $ allocate it (hClose . snd)
131− _ <- runInternalState (register $ removeFile fp) internalState
133+ _ <- runInternalState (register $ removeFileQuiet fp) internalState
132134 fix $ \loop -> do
133135 bs <- popper
134136 unless (S.null bs) $ do
@@ -140,6 +142,9 @@ tempFileBackEndOpts getTmpDir pattrn internalState _ _ popper = do
140142 it = do
141143 tempDir <- getTmpDir
142144 openBinaryTempFile tempDir pattrn
145+ removeFileQuiet fp = catchJust (guard . isDoesNotExistError)
146+ (removeFile fp)
147+ (const $ return ())
143148
144149-- | A data structure that describes the behavior of
145150-- the parseRequestBodyEx function.