Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Modify event on existing files #54

Closed
SpartanJ opened this issue Nov 27, 2013 · 8 comments
Closed

No Modify event on existing files #54

SpartanJ opened this issue Nov 27, 2013 · 8 comments
Labels
bug Something isn't working critical

Comments

@SpartanJ
Copy link
Owner

Original report by Roland Rosenkranz (Bitbucket: Glatzemann, GitHub: Glatzemann).


System: Windows 8.1
Compiler: Visual Studio 2012

Steps to reproduce:

  • use sample code from readme
  • start program watching a directory containing a text file
  • open the textfile and make some changes
  • save the textfile

No event is triggered. When creating a new file and modifying it after creation, everything works as expected.

@SpartanJ
Copy link
Owner Author

Original comment by Roland Rosenkranz (Bitbucket: Glatzemann, GitHub: Glatzemann).


The modification is recognized when file size changed only.

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


You are right! This is my fault, and the fix is simple, but there's a problem, IO Completion Ports will report 2 notifications events for the modified file ( it's a known issue ), and i need to add a filter to avoid reporting two times the same event. If you need a quick fix i can commit the fix without the filtering, but i prefer to commit the fix when is really fixed.

Thanks for reporting it, i'll try to fix this ASAP, since is critical.

@SpartanJ
Copy link
Owner Author

Original comment by Roland Rosenkranz (Bitbucket: Glatzemann, GitHub: Glatzemann).


I already found the simple fix myself (added FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS to CreateWatch call in FileWatcherWin32). Now I get the two notifications you talked about. This is ok for me at this time...

I'm looking forward for a fix. Thank you very much.

BTW: Very nice project

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


Fixed issue #14. Thanks Roland Rosenkranz for reporting it!

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


The bug should be fixed in the last commit.
I wanted to clarify a thing: if you use FILE_NOTIFY_CHANGE_LAST_ACCESS , you will have a Modified event every time you open the file, and that's not the correct behavior. So i only used FILE_NOTIFY_CHANGE_LAST_WRITE for the fix.

Regards,
Martín

@SpartanJ
Copy link
Owner Author

Original comment by Roland Rosenkranz (Bitbucket: Glatzemann, GitHub: Glatzemann).


You're right ;-)

I tested the fix (thank you for the fast fix) and it works, but I still had to make a small source modification to get it work. I had to increase the time in WatcherWin32.cpp from 10ms to 100ms because I still got double notifications.

Maybe this should be user configureable?

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


I think that i thought a bad solution with that fix.

I've changed the way i filter this duplicate event. Now i compare the Modification Time of the modified file, if it's the same the the last reported modified event, the event is ignored. It's a little bit slower ( since i need to 'stat' the file ), but nothing problematic ( unless you are changing thousand of files per second in a slow HD ).

If you have any problem, just let me know! But i think this is the correct solution.

Regards,
Martín

@SpartanJ
Copy link
Owner Author

Original comment by Roland Rosenkranz (Bitbucket: Glatzemann, GitHub: Glatzemann).


Works like a charm. Thank you very much.

@SpartanJ SpartanJ added critical bug Something isn't working labels Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical
Projects
None yet
Development

No branches or pull requests

1 participant