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

Add separate method for file/directory metadata modifcation #800

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fc9b03a
add fileattrib and dirattrib event
GreatBahram May 18, 2021
e693eb1
use fileattrib and dirattrib event in inotify module
GreatBahram May 18, 2021
2c66593
add on_attrib on LoggingEventHandler
GreatBahram May 18, 2021
937f9af
add changes to make kqueue support attrib event
GreatBahram May 26, 2021
e2d8db0
bring file/directory attribute change event into fsevents2 module
GreatBahram May 27, 2021
3a652ff
update docs for FileAttrib and DirAttrib Events
GreatBahram May 27, 2021
3b6f258
Make flake8 happy
GreatBahram Jun 1, 2021
151f651
Change the test github workflow
GreatBahram Jun 10, 2021
dc366d6
add on: pull_request workflow statement:
GreatBahram Jun 10, 2021
1ca76cb
WIP: fix two more test cases and make sure they work correctly on bsd…
GreatBahram Jun 10, 2021
c3dc00f
add test cases for file_attrib and dir_attrib
GreatBahram Jun 10, 2021
165a6f4
add chmod function into shell module and add test cases to test it wo…
GreatBahram Jun 10, 2021
b710851
I think I fixed the nested tese case
GreatBahram Jun 10, 2021
424cb47
Make flake8 happier than ever
GreatBahram Jun 10, 2021
58b514f
WIP: Disable the lifecycle test case
GreatBahram Jun 10, 2021
677ac9f
Update fsevents module: this should be tested more than any other mod…
GreatBahram Jun 10, 2021
467b1e2
bugfix test case: test_modify on BSD
GreatBahram Jun 24, 2021
5e94d19
return str repsentation instead of Pathlib object
GreatBahram Jun 24, 2021
60415b7
make the equality method more strict
GreatBahram Jun 24, 2021
9d0e19c
run test work for pull_request and when user asks for it
GreatBahram Jun 24, 2021
dfb27d6
bugfix: document
GreatBahram Jun 24, 2021
5921e2c
Update tests.yml
BoboTiG Jun 24, 2021
2f8b573
Merge branch 'master' into add-attributes-only
BoboTiG Mar 18, 2023
167639f
Update tests.yml
BoboTiG Mar 18, 2023
f751e7d
Update kqueue.py
BoboTiG Mar 18, 2023
482846e
Apply suggestions from code review
BoboTiG Mar 18, 2023
dfa6db5
Apply suggestions from code review
BoboTiG Mar 18, 2023
4987d2b
Merge branch 'master' into add-attributes-only
BoboTiG Apr 22, 2023
008556d
Update test_emitter.py
BoboTiG Apr 22, 2023
408738f
Apply suggestions from code review
BoboTiG Apr 22, 2023
7c8ac0b
Update test_emitter.py
BoboTiG Apr 22, 2023
25adb67
Apply suggestions from code review
BoboTiG Apr 22, 2023
4622197
Update test_emitter.py
BoboTiG Apr 22, 2023
af9436e
Update test_fsevents.py
BoboTiG Apr 22, 2023
8069705
Update test_emitter.py
BoboTiG Apr 24, 2023
6d03156
Update conftest.py
BoboTiG Apr 24, 2023
79bec88
Update utils.py
BoboTiG Apr 24, 2023
f1593f4
Update tests/test_fsevents.py
BoboTiG Apr 24, 2023
d2b3b24
Update tests/test_emitter.py
BoboTiG Apr 24, 2023
814d68e
Apply suggestions from code review
BoboTiG Apr 24, 2023
fe6c552
Merge branch 'master' into add-attributes-only
BoboTiG Jul 28, 2024
550ec1d
Apply suggestions from code review
BoboTiG Jul 28, 2024
6c8b6c7
Merge branch 'master' into add-attributes-only
BoboTiG Aug 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
BoboTiG authored Mar 18, 2023
commit 482846e7f9861fb37944a78c8b5c6d540c2126e8
6 changes: 3 additions & 3 deletions src/watchdog/events.py
Original file line number Diff line number Diff line change
@@ -113,8 +113,8 @@
EVENT_TYPE_CREATED = "created"
EVENT_TYPE_MODIFIED = "modified"
EVENT_TYPE_CLOSED = "closed"
EVENT_TYPE_OPENED = "opened"'
EVENT_TYPE_ATTRIB = 'attrib'
EVENT_TYPE_OPENED = "opened"
EVENT_TYPE_ATTRIB = "attrib"


class FileSystemEvent:
@@ -583,7 +583,7 @@ def on_modified(self, event):
def on_attrib(self, event):
super().on_attrib(event)

what = 'directory' if event.is_directory else 'file'
what = "directory" if event.is_directory else "file"
self.logger.info("Attrib %s: %s", what, event.src_path)


4 changes: 2 additions & 2 deletions src/watchdog/observers/fsevents.py
Original file line number Diff line number Diff line change
@@ -276,10 +276,10 @@ def queue_events(self, timeout, events):
if dst_event.is_modified:
self._queue_modified_event(dst_event, dst_path, dst_dirname)

if dst_event.is_inode_meta_mod or dst_event.is_xattr_mod:
elif dst_event.is_inode_meta_mod or dst_event.is_xattr_mod:
BoboTiG marked this conversation as resolved.
Show resolved Hide resolved
self._queue_attrib_event(dst_event, dst_path, dst_dirname)

if dst_event.is_removed:
elif dst_event.is_removed:
self._queue_deleted_event(dst_event, dst_path, dst_dirname)
self._fs_view.discard(dst_event.inode)

14 changes: 7 additions & 7 deletions tests/test_emitter.py
Original file line number Diff line number Diff line change
@@ -143,22 +143,22 @@ def test_modify(p: P, event_queue: TestEventQueue, start_watching: StartWatching
touch(p("a"))

if platform.is_windows():
expect_event(FileModifiedEvent(p('a')))
expect_event(FileModifiedEvent(p("a")))

if platform.is_linux():
# on Linux we'd get the attrib event first then
event = event_queue.get(timeout=5)[0]
assert isinstance(event, FileAttribEvent)
assert event.src_path == p('a')
assert event.src_path == p("a")

if platform.is_bsd():
event = event_queue.get(timeout=5)[0]
assert isinstance(event, FileModifiedEvent)
assert event.src_path == p('a')
assert event.src_path == p("a")

event = event_queue.get(timeout=5)[0]
assert isinstance(event, FileAttribEvent)
assert event.src_path == p('a')
assert event.src_path == p("a")


@pytest.mark.flaky(max_runs=5, min_passes=1, rerun_filter=rerun_filter)
@@ -413,7 +413,7 @@ def test_recursive_on(p: P, event_queue: TestEventQueue, start_watching: StartWa
assert isinstance(event, DirModifiedEvent)

event = event_queue.get(timeout=5)[0]
assert event.src_path == p('dir1', 'dir2', 'dir3', 'a')
assert event.src_path == p("dir1", "dir2", "dir3", "a")
assert isinstance(event, FileAttribEvent)


@@ -631,11 +631,11 @@ def test_move_nested_subdirectories(

if not platform.is_windows():
event = event_queue.get(timeout=5)[0]
assert event.src_path == p('dir2/dir3', 'a')
assert event.src_path == p("dir2/dir3", "a")
assert isinstance(event, FileAttribEvent)

if platform.is_linux():
expect_event(FileClosedEvent(p('dir2/dir3/', 'a')))
expect_event(FileClosedEvent(p("dir2/dir3/", "a")))

event = event_queue.get(timeout=5)[0]
assert event.src_path == p('dir2/dir3')
BoboTiG marked this conversation as resolved.
Show resolved Hide resolved