monitor dir create - #9
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances directory monitoring by adding support for detecting directory creation events and simplifying the fswatch branch.
- inotifywait now watches for both
moved_toandcreateevents and distinguishes between directory creation and move events. - Event parsing logic for inotifywait has been refined to separately report create vs. move directory events.
- fswatch branch logic simplified to treat any detected directory path as a directory event.
Comments suppressed due to low confidence (1)
monitor-dir.sh:100
- You've added
createevent handling in the inotifywait invocation—consider adding automated tests or integration checks to verify that directory creation events are correctly detected and reported.
inotifywait --exclude '(.tmp)' -r -m --format '%w%f %e' -e moved_to,create "$@" | while IFS= read -r line; do
Comment on lines
+104
to
+109
| if [[ "$line" == *"CREATE,ISDIR"* ]] || [[ "$line" == *"MOVED_TO,ISDIR"* ]]; then | ||
| # 使用更安全的方式解析路径和事件 | ||
| # 找到最后一个空格的位置,分离路径和事件 | ||
| event_part="${line##* }" | ||
| path_part="${line% *}" | ||
|
|
||
| echo "检测到目录移动事件: $path_part" | ||
| if [[ "$line" == *"CREATE,ISDIR"* ]]; then |
There was a problem hiding this comment.
The current string match assumes a fixed event order (CREATE,ISDIR or MOVED_TO,ISDIR). It would be more robust to split event_part on commas and check for the presence of CREATE/MOVED_TO and ISDIR independently, handling any order or additional flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.