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

Observation does not work on mac anymore: #797

Closed
idefixcert opened this issue May 12, 2021 · 3 comments · Fixed by #799
Closed

Observation does not work on mac anymore: #797

idefixcert opened this issue May 12, 2021 · 3 comments · Fixed by #799

Comments

@idefixcert
Copy link

idefixcert commented May 12, 2021

Hi and thanx for this library.

I have an Observer that listens on *.json files:

        event_handler = PatternMatchingEventHandler(patterns=["*.json"],
                                                    ignore_patterns=[],
                                                    ignore_directories=True)
        event_handler.on_any_event = self.load_daemon_map
        self.observer = Observer()
        self.observer.schedule(event_handler, self.pid_folder)
        self.observer.start()

And I create a simple test, that just creates a new File:
with watchdog 2.0.3 I get:

<FileCreatedEvent: event_type=created, src_path='/Users/chris/development/rtbrick/projects/cli2/mgmtd/tests/testdata/pidfolder/confd.json', is_directory=False>
<FileModifiedEvent: event_type=modified, src_path='/Users/chris/development/rtbrick/projects/cli2/mgmtd/tests/testdata/pidfolder/confd.json', is_directory=False>

But with watchdog 2.1.1 no event is fired anymore.

Do I miss anything or is this a bug?

This issue does not arrive at ubuntu/bionic:

load: <FileCreatedEvent: event_type=created, src_path='./tests/testdata/pidfolder/confd.json', is_directory=False>
load: <FileModifiedEvent: event_type=modified, src_path='./tests/testdata/pidfolder/confd.json', is_directory=False>
load: <FileClosedEvent: event_type=closed, src_path='./tests/testdata/pidfolder/confd.json', is_directory=False>
@oprypin
Copy link
Contributor

oprypin commented May 12, 2021

I can confirm this via GitHub Actions.

Run where only Mac doesn't produce any events:
https://github.com/oprypin/watchdog/runs/2567960137?check_suite_focus=true

Source code:
https://github.com/oprypin/watchdog/compare/60fc1b6ecdab538751ac0f3000448230660e4f6f

@oprypin
Copy link
Contributor

oprypin commented May 12, 2021

And a bisect:
https://github.com/oprypin/watchdog/runs/2568398200?check_suite_focus=true

1c67997 is the first bad commit

Source code:
oprypin@1e9e2a4

CCP-Aporia added a commit to CCP-Aporia/watchdog that referenced this issue May 18, 2021
This works for me locally, let's see what the CI machine says.
@CCP-Aporia
Copy link
Contributor

CCP-Aporia commented May 18, 2021

Hey, thanks for reporting this problem! Unfortunately I cannot seem to reproduce the issue. Could you take a look at the test I've added in my fork, and see if there's anything missing in it?

Nevermind, I've found the problem. It seems the watch path is not fully normalised, and as such the recursive check fails to fully understand the usage of "." as the observed folder.

CCP-Aporia added a commit to CCP-Aporia/watchdog that referenced this issue May 18, 2021
A watch path may be relative, while an event path is always absolute. Since the check for recursive events simply compared the watch path with the event path then that would fail in case the watch was set to a relative folder. This resolves the issue.

Fixes gorakhargosh#797
BoboTiG added a commit that referenced this issue May 19, 2021
…bserver (#799)

* Add test for issue #797

This works for me locally, let's see what the CI machine says.

* Use absolute watch path in recursive check

A watch path may be relative, while an event path is always absolute. Since the check for recursive events simply compared the watch path with the event path then that would fail in case the watch was set to a relative folder. This resolves the issue.

Fixes #797

* Add support for ~ in watch path

Same problem as relative paths.

* Update changelog.rst

Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants