on master help sign in
Fix inappropriate type (Not a directory) error
842d0caRanjeet Kumar Ranjan
src/Streamly/Internal/FileSystem/Event/Linux.hs+3−1
@@ -193,6 +193,7 @@ import qualified Streamly.Internal.Data.Fold as FL
193import qualified Streamly.Internal.Data.Parser as PR
193import qualified Streamly.Internal.Data.Parser as PR
194import qualified Streamly.Internal.Data.Stream.IsStream as S
194import qualified Streamly.Internal.Data.Stream.IsStream as S
195import qualified Streamly.Internal.FileSystem.Dir as Dir
195import qualified Streamly.Internal.FileSystem.Dir as Dir
196+import qualified System.Directory as Dir
196import qualified Streamly.Internal.FileSystem.Handle as FH
197import qualified Streamly.Internal.FileSystem.Handle as FH
197import qualified Streamly.Internal.Unicode.Stream as U
198import qualified Streamly.Internal.Unicode.Stream as U
198
199
@@ -745,7 +746,8 @@ addToWatch cfg@Config{..} watch0@(Watch handle wdMap) root0 path0 = do
745 --
746 --
746 -- XXX toDirs currently uses paths as String, we need to convert it
747 -- XXX toDirs currently uses paths as String, we need to convert it
747 -- to "/" separated by byte arrays.
748 -- to "/" separated by byte arrays.
749+ pathIsDir <- Dir.doesDirectoryExist $ utf8ToString absPath
748− when watchRec $ do
750+ when (watchRec && pathIsDir) $ do
749 S.mapM_ (\p -> addToWatch cfg watch0 root (appendPaths path p))
751 S.mapM_ (\p -> addToWatch cfg watch0 root (appendPaths path p))
750 $ S.mapM toUtf8
752 $ S.mapM toUtf8
751 $ Dir.toDirs $ utf8ToString absPath
753 $ Dir.toDirs $ utf8ToString absPath
src/Streamly/Internal/FileSystem/Event/Windows.hs+4−4
@@ -12,13 +12,13 @@
12--
12--
13-- =Overview
13-- =Overview
14--
14--
15−-- Use 'watchTrees'or 'watchPaths' with a list of file system paths you want to
15+-- Use 'watchRecursive'or 'watch' with a list of file system dir paths you
16−-- watch as argument. It returns a stream of 'Event' representing the file
16+-- want to watch as argument. It returns a stream of 'Event' representing the
17−-- system events occurring under the watched paths.
17+-- file system events occurring under the watched paths.
18--
18--
19-- @
19-- @
20-- {-\# LANGUAGE MagicHash #-}
20-- {-\# LANGUAGE MagicHash #-}
21−-- Stream.mapM_ (putStrLn . 'showEvent') $ 'watchTrees' [Array.fromCString\# "path"#]
21+-- Stream.mapM_ (putStrLn . 'showEvent') $ 'watchRecursive' [Array.fromCString\# "path"#]
22-- @
22-- @
23--
23--
24-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)
24-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)
test/Streamly/Test/FileSystem/Event/Linux.hs+1−1
@@ -149,4 +149,4 @@ main = do
149 runRec SymLinkOrigPath recSymTests
149 runRec SymLinkOrigPath recSymTests
150 -- XXX This fails with exceptions, ideally it should work the same as in
150 -- XXX This fails with exceptions, ideally it should work the same as in
151 -- non-recursive mode
151 -- non-recursive mode
152− -- runRec FileType fileRootTests
152+ runRec FileType fileRootTests
test/Streamly/Test/FileSystem/Event/Windows.hs+1
@@ -38,6 +38,7 @@ main = do
38 -- TODO create/modify/delete/move with root path as a regular file, copy
38 -- TODO create/modify/delete/move with root path as a regular file, copy
39 -- from macOS tests
39 -- from macOS tests
40 -- run FileType fileRootTests
40 -- run FileType fileRootTests
41+ -- Windows watch events only supports dir path as root.
41
42
42 let recTests =
43 let recTests =
43 [ dirCreateWithParent "subdir\\dir"
44 [ dirCreateWithParent "subdir\\dir"