]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
MovedIn
authorFrank Doepper <[email protected]>
Tue, 26 Jun 2018 06:37:22 +0000 (08:37 +0200)
committerFrank Doepper <[email protected]>
Tue, 26 Jun 2018 06:55:12 +0000 (08:55 +0200)
agitprop.hs

index c5b0bf873bdadf1647477056e3edc44566147f04..6bfc3ab617f434ab38828150fdfba946c07d1437 100644 (file)
@@ -18,7 +18,6 @@ import qualified System.Posix.Files as F
 main :: IO ()
 main = do
   hr "starting"
-    --  tid <- myThreadId
   args <- getArgs >>= parseargs "agitprop"
   printparam' "client version" $ "amqp-utils " ++ (showVersion version)
   printparam' "routing key" $ rKey args
@@ -49,7 +48,11 @@ main = do
     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
@@ -59,7 +62,7 @@ main = do
       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 ()
@@ -79,4 +82,5 @@ confirmCallback (deliveryTag, isAll, ackType) =
 -- | 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 ()