main :: IO ()
main = do
hr "starting"
- -- tid <- myThreadId
args <- getArgs >>= parseargs "agitprop"
printparam' "client version" $ "amqp-utils " ++ (showVersion version)
printparam' "routing key" $ rKey args
then do
inotify <- initINotify
wd <-
- addWatch inotify [Close] (inputFile args) (handleEvent publishOneMsg)
+ addWatch
+ inotify
+ [Close, MoveIn]
+ (inputFile args)
+ (handleEvent publishOneMsg)
hr (inputFile args)
_ <- forever $ threadDelay 1000000
removeWatch wd
if (lineMode args)
then mapM_ publishOneMsg (BL.lines messageFile)
else publishOneMsg messageFile
- -- all done. wait and close.
+ -- all done. wait and close.
if (confirm args)
then waitForConfirms chan >>= return . show >> return ()
else return ()
-- | hotfolder event handler
handleEvent :: (BL.ByteString -> IO ()) -> Event -> IO ()
handleEvent f (Closed False (Just x) True) = hr x >> BL.readFile x >>= f
+handleEvent f (MovedIn False x _) = hr x >> BL.readFile x >>= f
handleEvent _ _ = return ()