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

Trailing slashes for directory watches #35

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

Conversation

toconnor
Copy link

inotifytools_watch_files() will append a / to any filename that is
is a directory before invoking create_watch()

update watch_from_filename() to search for filenames with a trailing /
if filename itself isn't found in tree_filename first

is a directory before invoking create_watch()

update watch_from_filename to search for filenames with a trailing /
if filename itself isn't found in tree_filename first
@ericcurtin ericcurtin force-pushed the master branch 27 times, most recently from e6aacf3 to 67b6e71 Compare February 1, 2020 19:03
@ericcurtin
Copy link
Member

@toconnor I'd like to merge this if at all possible. How could I reproduce the issue? Even better if you could add an integration test or a unit test.

@toconnor
Copy link
Author

toconnor commented Feb 2, 2020

@ericcurtin I no longer have access to the original codebase where I encountered this issue. I'll have to see if I can reproduce this issue. From what I can remember, if I created a watch on a directory, if the path string did not have a trailing slash, inotifytools would add one (

// Always end filename with / if it is a directory
if ( !isdir(filenames[i])
|| filenames[i][strlen(filenames[i])-1] == '/') {
filename = strdup(filenames[i]);
}
else {
nasprintf( &filename, "%s/", filenames[i] );
}
). If I went to query for the watch handle using a path string without a trailing slash (i.e., the exact string I passed to inotifytools_watch_files()), watch_from_filename() wouldn't find the watch.

@ericcurtin
Copy link
Member

@toconnor ok no problem :)

Just remember to respect backwards compatibility

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