From 98a2d1e6c69161f7ea0e5418157385568826fee3 Mon Sep 17 00:00:00 2001 From: Frank Doepper Date: Tue, 10 Jul 2018 16:27:18 +0200 Subject: [PATCH] hinotify 0.3.10 compat --- agitprop.hs | 13 +++++++++++++ amqp-utils.cabal | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/agitprop.hs b/agitprop.hs index 480307a..bd03adc 100644 --- a/agitprop.hs +++ b/agitprop.hs @@ -1,8 +1,12 @@ +{-# LANGUAGE CPP #-} -- generic AMQP publisher import Control.Concurrent (threadDelay) import qualified Control.Exception as X import Control.Monad (forever) import qualified Data.ByteString.Lazy.Char8 as BL +#if MIN_VERSION_hinotify(0,3,10) +import qualified Data.ByteString.Char8 as BS +#endif import Data.List (isSuffixOf) import Data.Maybe import qualified Data.Text as T @@ -51,7 +55,11 @@ main = do addWatch inotify [CloseWrite, MoveIn] +#if MIN_VERSION_hinotify(0,3,10) + (BS.pack (inputFile args)) +#else (inputFile args) +#endif (handleEvent publishOneMsg (suffix args) (inputFile args)) hr $ "BEGIN watching " ++ (inputFile args) _ <- forever $ threadDelay 1000000 @@ -91,8 +99,13 @@ handleEvent :: -> Event -> IO () -- just handle closewrite and movedin events +#if MIN_VERSION_hinotify(0,3,10) +handleEvent f s p (Closed False (Just x) True) = handleFile f s (p ++ "/" ++ (BS.unpack x)) +handleEvent f s p (MovedIn False x _) = handleFile f s (p ++ "/" ++ (BS.unpack x)) +#else handleEvent f s p (Closed False (Just x) True) = handleFile f s (p ++ "/" ++ x) handleEvent f s p (MovedIn False x _) = handleFile f s (p ++ "/" ++ x) +#endif handleEvent _ _ _ _ = return () -- | Hotfolder file handler diff --git a/amqp-utils.cabal b/amqp-utils.cabal index a32fbbb..cc6c164 100644 --- a/amqp-utils.cabal +++ b/amqp-utils.cabal @@ -68,7 +68,7 @@ executable agitprop tls, amqp >=0.17, unix >= 2.7, - hinotify >= 0.3.8 && < 0.3.10, + hinotify >= 0.3.8, magic ghc-options: -threaded -Wall -- 2.39.5