Skip to content

Comments

Allow recursive watch with --include#229

Merged
ericcurtin merged 1 commit intoinotify-tools:masterfrom
arnib:master
Dec 20, 2024
Merged

Allow recursive watch with --include#229
ericcurtin merged 1 commit intoinotify-tools:masterfrom
arnib:master

Conversation

@arnib
Copy link
Contributor

@arnib arnib commented Dec 18, 2024

This addition changes the functionality of the --recursive flag when it's used with --include.

Prior to the change, when watching a folder recursively, watches are not added for newly created subdirectorires unless they match the filter.

With this change, folders are not matched against the filter when deciding to monitor them recursively.

Scenario:

  1. Create a folder /tmp/x
  2. Run inotifywait -r -i "txt$" /tmp/x
  3. Create a file /tmp/x/test.txt -> inotifywait notices the creation
  4. Create a file /tmp/x/test -> inotifywait does not notice it (because it does not match include filter)
  5. Create a folder /tmp/x/y.txt/ -> inotify notices the creation and monitors recursively
  6. Create a file /tmp/x/y.txt/test -> inotify notices the creation (because it's monitoring /tmp/x.txt/ recursively

Prior to the changes:
7. Create a folder /tmp/x/z/ -> inotify does not notice this or set recursive watch (because it does not match the filter)
8. Create a file /tmp/x/z/test.txt -> inotify does not notice, since it's not recursively watching.

With the changes:
7. Create a folder /tmp/x/z/ -> inotify sets a recursive watch on this folder, even if it does not match the filter
8. Create a file /tmp/x/z/test.txt -> inotify notices this file because it's watching recursively and it matches the filter

There are multiple mentions of this or similar issues in the Issues list, and I hit the same issue when starting to use inotifywait:
#224
#199
#168

@arnib
Copy link
Contributor Author

arnib commented Dec 20, 2024

@ericcurtin Could you have a look at this suggestion? :-)

Copy link
Member

@ericcurtin ericcurtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the builds pass I don't see any reason why we shouldn't merge this :)

@ericcurtin ericcurtin merged commit c99b84b into inotify-tools:master Dec 20, 2024
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

Successfully merging this pull request may close these issues.

2 participants