haskell-fswatch / hfsnotify

Unified Haskell interface for basic file system notifications
BSD 3-Clause "New" or "Revised" License
136 stars 40 forks source link

`watchTree*` and creating new subdirectories #67

Closed sgraf812 closed 6 years ago

sgraf812 commented 7 years ago

New subdirectories aren't immediately watched:

#!/usr/bin/env stack
-- stack --resolver lts-7.4 --install-ghc runghc --package fsnotify --package directory --package temporary

import Control.Concurrent
import System.FSNotify
import System.FilePath
import System.Directory
import System.IO.Temp

main = 
  withSystemTempDirectory "fsnotify" $ \baseDir -> 
  withManager $ \mgr -> do
    _ <- watchTree mgr baseDir (const True) print
    writeFile (baseDir </> "file.txt") "whuzza"
    let childDir = baseDir </> "child"
    createDirectoryIfMissing True childDir
    -- threadDelay (10*1000)
    writeFile (childDir </> "child.txt") "whoop"
    threadDelay (1000*1000)

This prints only one line, instead of the expected two when that line is uncommented.

Also, this works as expected on OS X, but not on my Linux VM.