From: Frank Doepper Date: Mon, 21 Aug 2023 15:28:03 +0000 (+0200) Subject: WiP rabbit hole X-Git-Url: https://woffs.de/git/fd/haskell-amqp-utils.git/commitdiff_plain/refs/heads/ospath WiP rabbit hole --- diff --git a/agitprop.hs b/agitprop.hs index cb1db39..445f686 100644 --- a/agitprop.hs +++ b/agitprop.hs @@ -123,8 +123,10 @@ watchHotfolder args publishOneMsg (folder, exchange, rkey) = do (handleEvent (publishOneMsg exchange rkey) (suffix args) folder) hr "BEGIN watching" if (initialScan args) - then DO.listDirectory folder >>= - mapM_ (\fn -> handleFile (publishOneMsg exchange rkey) (suffix args) (folder OS. fn)) + then do + folder' <- OS.encodeUtf (BS.unpack folder) + DO.listDirectory folder' >>= + mapM_ (\fn -> handleFile (publishOneMsg exchange rkey) (suffix args) (folder' OS. fn)) else return () return (wd,folder) #endif @@ -152,7 +154,7 @@ confirmCallback (deliveryTag, isAll, ackType) = #if linux_HOST_OS -- | Hotfolder event handler handleEvent :: - (Maybe RawFilePath -> BL.ByteString -> IO ()) -> [BS.ByteString] -> RawFilePath -> Event -> IO () + (Maybe RawFilePath -> BL.ByteString -> IO ()) -> [BS.ByteString] -> OS.OsPath -> Event -> IO () -- just handle closewrite and movedin events handleEvent func suffixes folder (Closed False (Just fileName) True) = handleFile func suffixes (folder OS. fileName) @@ -162,7 +164,7 @@ handleEvent _ _ _ _ = return () -- | Hotfolder file handler handleFile :: - (Maybe RawFilePath -> BL.ByteString -> IO ()) -> [BS.ByteString] -> RawFilePath -> IO () + (Maybe RawFilePath -> BL.ByteString -> IO ()) -> [BS.ByteString] -> OS.OsPath -> IO () handleFile func suffixes@(_:_) fileName = if (any (flip BS.isSuffixOf fileName) suffixes) && not ("." `BS.isPrefixOf` fileName) then handleFile func [] fileName