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

Support watching the same inode through multiple paths. #573

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hugwijst
Copy link

@hugwijst hugwijst commented Mar 8, 2024

Support watching the same inode through multiple paths.

As a single change event can now refer to multiple paths, use "path groups" for renames to differentiate sources and destinations.

Fixes #572.

As a single change event can now refer to multiple paths, use "path
groups" for renames to differentiate sources and destinations.

Fixes notify-rs#572.
/// in distinct groups.
///
/// If there are different path groups, the `path_group_split_index` attribute indicates the
/// first index with paths in the second group.
pub paths: Vec<PathBuf>,
Copy link
Author

Choose a reason for hiding this comment

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

As this is a behavioral change, we probably want some kind of API change so users explicitly decide how to handle multiple paths in one group, or this newly introduced concept of 2 different groups.

I didn't want to break this into two separate vectors, as to not increase the size of the Event struct. Maybe we should make paths private and have a fn path_groups(&self) -> (&[PathBuf], Option<&[PathBuf]>) method?

Copy link
Member

Choose a reason for hiding this comment

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

How about instead of having the api on the attrs interact directly with the fields, there's a more intuitive API on Event like renamed_from_paths() -> Option<&[Path]> and renamed_to_paths() -> Option<&[Path]> that interprets the kind/paths/attr information?

Copy link
Author

Choose a reason for hiding this comment

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

I don't see a good way to only expose these APIs on renames only. Are you proposing to check the event kind and only return Some in case of a rename?

Copy link
Member

Choose a reason for hiding this comment

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

I was, yes.

@hugwijst
Copy link
Author

hugwijst commented Apr 3, 2024

Ping @dfaust, @0xpr03. I'm wondering if there is a less intrusive solution?

@hugwijst
Copy link
Author

Ping @passcod, @dfaust, @0xpr03, would any of you be able to review?

The current implementation is buggy if the watched directory contains two hard or symbolic links to the same file. I can see an argument for symbolic links to not be followed at all, but something like this change is needed for hard links I think.

@hugwijst
Copy link
Author

After revisiting this PR I think the ignoring symlink while walking the directories is the better solution to my problem: #635. Some of the changes here might still be useful to handle hardlinks.

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.

inotify: files pointed at by multiples symlinks generate events only for one path
2 participants