SpartanJ / efsw

efsw is a C++ cross-platform file system watcher and notifier.
Other
662 stars 101 forks source link

Generic watcher fails to watch sub-sub directories #143

Closed fishcatcher closed 2 years ago

fishcatcher commented 2 years ago

Hi, I have the following structure: A: --\B: ----\C: ------\CC:

If I watch "A\B" which recursive is set to true, the followings happen: 1) Every change in B is detected (correct behavior) 2) In "C", only file (add/remove) is detected, folder change (add/remove) is NOT detected 3) In "CC", neither file or folder change is detected (For 2 and 3, the working folder is reported as modified) 4) If you go 3 levels deep from the watched folder, none of the action is reported (including the working directory being reported as modified )

SpartanJ commented 2 years ago

@fishcatcher Hi, thanks for reporting it, I'll take a look later. I'm curious on why are you using the generic watcher? It's there more like an example of a watcher implementation than something that can be used in production environments, its performance will be really poor in comparison with the specific OS implementation of the watcher.

fishcatcher commented 2 years ago

We're using the generic implementation to watch a network drive.

SpartanJ commented 2 years ago

I'm unable to reproduce it. Can you provider a minimal code example to reproduce it? Thanks.

fishcatcher commented 2 years ago

Hi, It's just this simple code:

int main()
{
    std::cout << "Hello World!\n";

    /// create the file watcher object
    efsw::FileWatcher fileWatcher(true);
    /// starts watching
    fileWatcher.watch();

    efsw::System::sleep(1000);

    UpdateListener* ul = new UpdateListener();
    efsw::WatchID id = fileWatcher.addWatch("C:\\Users\\Frog\\Desktop\\TestWatchFolder", ul, true);
    handleWatchID(id);

    while (true)
    {
        efsw::System::sleep(100);
    }

    return 0;
}

Additional info: If TestWatchFolder is empty before you run the watch, it works, all changes are detected no matter how nested. But if the TestWatchFolder already has nested folders, i.e. C:\Users\Frog\Desktop\TestWatchFolder\B\C\D\E\F\G\H\E then it won't detect changes like reported.

SpartanJ commented 2 years ago

I pushed some fixes for the issue. Let me know if it's working for you.

fishcatcher commented 2 years ago

I pushed some fixes for the issue. Let me know if it's working for you.

That fixes it, thank you!