-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New file is not detected when renaming the sub-folder of the watched folder (Java 7 WatchService) #8659
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
Comments
I think you need to add So, looks like when we rename the dir, a Or do you mean the Is that what you try to explain? Looking to the code I really don't see that we react properly to the Thanks |
Yes, I will give a try. I wasn't aware that DELETE event is used for directory renaming.
Yes, exactly. When You execute the code in the debugger You will notice that this operation: WatchKey watchKey = dir.register(this.watcher, this.kinds); returns the same watchKey object for the renamed directory as that which is already present in the pathKeys. (I assume that the renamed folder is identified internally by some identifier which stays untouched after rename operation...). However, the path which is resolved from the event (for the file copied into the renamed directory) is incorrect! That’s why I am not sure if this problem is not related to the WhatchService ?
Yes, it seems the watcher doesn't register the renamed folder internally as it seems it “thinks” it is the same folder that has been already registered - that’s why the wrong path is used in the event.
Yes, good point !
I totally agree. I simply didn't know that DELETE event is used in renaming operation.
|
And from here we are totally opened to see a contribution via Pull Request: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc |
…t new file after renaming the sub-folder of the watched folder (Java 7 WatchService)
Hello @artembilan, I've prepared a PR with a simple fix according to this thread (support DELETE event by default and remove from this.pathKeys): #8662. |
Fixes #8659 * GH-8659: Updating the documentation as requested * GH-8659: Fixes requested after coder review **Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`** (cherry picked from commit 0798c8d) # Conflicts: # spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
Fixes #8659 * GH-8659: Updating the documentation as requested * GH-8659: Fixes requested after coder review **Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`** (cherry picked from commit 0798c8d) # Conflicts: # spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
Uh oh!
There was an error while loading. Please reload this page.
In what version(s) of Spring Integration are you seeing this issue?
6.0.1.RELEASE
Describe the bug
The bug is related to the FileReadingMessageSource when using it for watching the directory with the (Java 7) WatchService feature enabled.
More specifically, the new files are not detected in the sub-directory of the watched folder after renaming it.
This issue has been discovered on Windows when using File Explorer to create a new directory ('New Folder' temporary name is used initially and user edits the name after that). In such a case 2 file events are generated.
To Reproduce
Expected behavior
The file is detected properly in the sub-directory after renaming this sub-directory in the watched folder.
Sample
//TBC
The fix that seems to solve the issue on Windows (not sure about other OS'es) - the only method changed in the FileReadingMessageSource is registerWatch:
Potentially the ExtendedWatchEventModifier.FILE_TREE modifier can be used for that but it seems it is only working for Windows.
The text was updated successfully, but these errors were encountered: