Giter Club home page Giter Club logo

Comments (9)

SpartanJ avatar SpartanJ commented on August 29, 2024

Thank you very much for reporting the issue. This is interesting, I did not expect it to happen and the Windows documentation does not clarify about it, this was implemented assuming that the event FILE_ACTION_RENAMED_NEW_NAME comes always right after a FILE_ACTION_RENAMED_OLD_NAME event (we could have other events types in between though).
This is only fixable if and only if Windows reports the events in FIFO, if this is not the case this is a kernel bug and is un-fixable, so I'll assume that this is the case an implement it as a FIFO queue.

from efsw.

solarispika avatar solarispika commented on August 29, 2024

I find this article which might explain why such behavior can happen.
Basically, the function is not designed for file monitoring but for file listing from the beginning.

The intended purpose of the Read­Directory­ChangesW function is to assist programs like Windows Explorer which display the contents of a directory. If something happens that results in a change to the directory listing, then it is reported by Read­Directory­ChangesW. In other words, Read­Directory­ChangesW tells you when the result of a Find­First­File/Find­Next­File loop changes. The intended usage pattern is doing a Find­First­File/Find­Next­File to collect all the directory entries, and then using the results from Read­Directory­ChangesW to update that collection incrementally.

from efsw.

solarispika avatar solarispika commented on August 29, 2024

I managed to fix the issue by ReadDirectoryChangesExW since it provides file id for comparing.
However, the function needs newer OS and it only supports NTFS, this makes it less useful for this project.

from efsw.

SpartanJ avatar SpartanJ commented on August 29, 2024

Could you share the changes? It's possible to detect the OS version and the disk file system and use this particular more fine-grained version.

from efsw.

solarispika avatar solarispika commented on August 29, 2024

Sure, here it is. poc-fix-rename-issue.patch
The patch contains debug logs and some experimental code, so don't be serious on it :-)

To use the patch, some macro is needed to set sdk version.
I use cmake for building, and the command line argument for configuration has -DCMAKE_CXX_FLAGS_INIT="/DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00".

With this patch, I can't reproduce the problem.

from efsw.

SpartanJ avatar SpartanJ commented on August 29, 2024

Ohh I see, very interesting, thanks for sharing it, I'll try to provide the feature at least optionally. But as you can see, all these file system monitoring APIs are very messy and you'll encounter things like the one you encountered quite easily. efsw already tries to do more than most libraries to get it as close to "right" as possible.

from efsw.

SpartanJ avatar SpartanJ commented on August 29, 2024

I implemented something based on your fix. ReadDirectoryChangesExW will be detected dynamically and used if available.

from efsw.

solarispika avatar solarispika commented on August 29, 2024

It looks like file systems which ReadDirectoryChangesExW doesn't support will fail to be watched on Windows versions that support the function.
I think monitored filesystem should also be considered.
Maybe we can try running ReadDirectoryChangesExW first and see if it fail or not.

from efsw.

SpartanJ avatar SpartanJ commented on August 29, 2024

Good observation, now ReadDirectoryChangesW is used as fallback. Thanks

from efsw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.