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

How to monitor event when the file is closed? #367

Closed
igordavid opened this issue Aug 2, 2016 · 5 comments
Closed

How to monitor event when the file is closed? #367

igordavid opened this issue Aug 2, 2016 · 5 comments

Comments

@igordavid
Copy link

Hello,

We have a problem with using Watchdog when we want to detect when the write has been finished and file is closed.

At the moment we can't do that as we are seeing "Created" when the file is initially created, and "Modified" once the file is being written to. But nothing related to "Closed".

Is there any way to monitor if the file is closed?

Thanks in advance!

@DonyorM
Copy link
Contributor

DonyorM commented Aug 24, 2016

I don't think this is possible. Programs like Microsoft word write files in an in-memory buffer. This has no interaction with the file system. When you "save" a file it either modifies or overwrites the old file with the content from the buffer. However, closing the buffer (the window) has no effect on the file system therefore cannot be detected. You're better off seeing if the program writing the file has a way for you to hook into it, and using an api call to run a method when the window closing.

@danilobellini
Copy link
Collaborator

If you're dealing with Linux systems, you seem to be looking for the IN_CLOSE_WRITE inotify event: http://man7.org/linux/man-pages/man7/inotify.7.html

@danilobellini
Copy link
Collaborator

This is a duplicate of #313, and would be solved by the enhancement proposal #217.

@igordavid
Copy link
Author

Thanks - initially, we were using inotify which have IN_CLOSE_WRITE event and it worked nice. Then we switched to watchdog because of some advanced features which inotify didn't had, but then we reverted back to inotify because of no CLOSE_WRITE mechanism.

Thanks for the answers and looking forward for this implementation in watchdog.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 15, 2021

Finally implemented the inotify part with 2fab7c2 (will be part of the 1.0.3 version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants