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

Watchfiles does not report changes made by a different user in a directory #241

Closed
pallavg opened this issue Aug 16, 2023 · 5 comments
Closed

Comments

@pallavg
Copy link

pallavg commented Aug 16, 2023

I launch watchfiles to observe a directory path /a/b/c as userA. If userA adds/removes a file in /a/b/c, watchfiles can detect changes just fine. However, if userB puts a file in /a/b/c, watchfiles just ignores those. Is there some setting/mechanism thereby which, I can tell watchfiles to detect any changes irrespective of which user added/removed files? Thanks.

@samuelcolvin
Copy link
Owner

It would be helpful if you could include which OS you're using and any other details.

It might be fixed by setting force_polling.

@pallavg
Copy link
Author

pallavg commented Aug 16, 2023

  1. I'm using SUSE Enterprise LInux version 12.

  2. I instantiate the watcher as follows. I am not doing anything special.

 class MyFilter(DefaultFilter):
     allowed_extensions = '.txt', '.txt.gz'
     def __call__(self, change: Change, path: str) -> bool:
         return super().__call__(change, path) and path.endswith(self.allowed_extensions) and change == Change.added  

def _process(changes):
     """Process added  files."""

     for _, spofi_file in changes:
         log.info('Process %s', spofi_file)

def main()
    ....
    _incoming_dir = Path('/a/b/c').resolve()
    run_process(_incoming_dir, target=None, callback=_process, watch_filter=MyFilter(), step=30000)

@samuelcolvin
Copy link
Owner

Is it fixed by using force polling.

@pallavg
Copy link
Author

pallavg commented Aug 16, 2023

Yes, it seems be working ok if I do

os.environ['WATCHFILES_FORCE_POLLING'] = '1'

run_process(...)

@samuelcolvin
Copy link
Owner

samuelcolvin commented Aug 16, 2023

Okay, well then it's a limitation of either the notify crate, or more likely the OS notifications system.

Happy to accept a PR to add force_polling: bool = False to run_process.

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

2 participants