, connect_timeout :: Int
, simple :: Bool
, cleanupTmpFile :: Bool
+ , removeSentFile :: Bool
}
instance Default Args where
600
False
False
+ False
-- | all options
allOptions :: [(String, OptDescr (Args -> Args))]
["suffix"]
(ReqArg (\s o -> o {suffix = s : (suffix o)}) "SUFFIX")
"Allowed file suffixes in hotfolder mode")
+ , ( "a"
+ , Option
+ ['u']
+ ["remove"]
+ (NoArg (\o -> o {removeSentFile = not (removeSentFile o)}))
+ ("Toggle removal of sent file (default: " ++ show (removeSentFile def) ++ ")"))
, ( "a"
, Option
['m']
import Network.AMQP.Utils.Helpers
import Network.AMQP.Utils.Options
import Paths_amqp_utils (version)
+import System.Directory (removeFile)
import System.Environment
import System.Exit
import System.INotify
(\e -> printparam "exception in handleFile" (e :: X.SomeException))
-- | Publish one message with our settings
-publishOneMsg' :: Channel -> Args -> Maybe String -> BL.ByteString -> IO ()
+publishOneMsg' :: Channel -> Args -> Maybe FilePath -> BL.ByteString -> IO ()
publishOneMsg' c a fn f = do
printparam "sending" fn
(mtype, mencoding) <-
, msgHeaders = substheader (fnheader a) fn $ msgheader a
} >>=
printparam "sent"
+ removeSentFileIfRequested (removeSentFile a) fn
where
substheader ::
[String] -> Maybe String -> Maybe FieldTable -> Maybe FieldTable
substheader (s:r) (Just fname) old =
substheader r (Just fname) (addheader old (s ++ "=" ++ fname))
substheader _ _ old = old
+ removeSentFileIfRequested False _ = return ()
+ removeSentFileIfRequested True Nothing = return ()
+ removeSentFileIfRequested True (Just fname) = printparam "removing" fname >> removeFile fname