@@ -59,10 +59,12 @@ import Data.List (sortBy)
59import Data.Function (on, fix)
59import Data.Function (on, fix)
60import System.Directory (removeFile, getTemporaryDirectory)
60import System.Directory (removeFile, getTemporaryDirectory)
61import System.IO (hClose, openBinaryTempFile)
61import System.IO (hClose, openBinaryTempFile)
62+import System.IO.Error (isDoesNotExistError)
62import Network.Wai
63import Network.Wai
63import qualified Network.HTTP.Types as H
64import qualified Network.HTTP.Types as H
64import Control.Applicative ((<$>))
65import Control.Applicative ((<$>))
66+import Control.Exception (catchJust)
65−import Control.Monad (when, unless)
67+import Control.Monad (when, unless, guard)
66import Control.Monad.Trans.Resource (allocate, release, register, InternalState, runInternalState)
68import Control.Monad.Trans.Resource (allocate, release, register, InternalState, runInternalState)
67import Data.IORef
69import Data.IORef
68import Network.HTTP.Types (hContentType)
70import Network.HTTP.Types (hContentType)
@@ -128,7 +130,7 @@ tempFileBackEndOpts :: IO FilePath -- ^ get temporary directory
128 -> IO FilePath
130 -> IO FilePath
129tempFileBackEndOpts getTmpDir pattrn internalState _ _ popper = do
131tempFileBackEndOpts getTmpDir pattrn internalState _ _ popper = do
130 (key, (fp, h)) <- flip runInternalState internalState $ allocate it (hClose . snd)
132 (key, (fp, h)) <- flip runInternalState internalState $ allocate it (hClose . snd)
131− _ <- runInternalState (register $ removeFile fp) internalState
133+ _ <- runInternalState (register $ removeFileQuiet fp) internalState
132 fix $ \loop -> do
134 fix $ \loop -> do
133 bs <- popper
135 bs <- popper
134 unless (S.null bs) $ do
136 unless (S.null bs) $ do
@@ -140,6 +142,9 @@ tempFileBackEndOpts getTmpDir pattrn internalState _ _ popper = do
141 tempDir <- getTmpDir
143 tempDir <- getTmpDir
142 openBinaryTempFile tempDir pattrn
144 openBinaryTempFile tempDir pattrn
145+ removeFileQuiet fp = catchJust (guard . isDoesNotExistError)
144-- | A data structure that describes the behavior of
149-- | A data structure that describes the behavior of
145-- the parseRequestBodyEx function.
150-- the parseRequestBodyEx function.