-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Filesystem] When a file gets overwritten, there is no event saying the file has been updated #4838
Comments
It's strange DELETED + ADDED should be translated to UPDATED: https://github.com/theia-ide/theia/blob/master/packages/filesystem/src/node/file-change-collection.ts#L29 We are using nsfw for fs watching, buffer and translate events from it. It would be interesting to record all raw nsfw events on |
I did some quick investigation with nsfw, and what seems to be happening is that when a file is overwritten you only get a |
if URIs are different, then it works as expected. |
I'm not sure it's clear what I meant. Let me describe a few uses cases:
The last example is not correct, or at least the behaviour is not what I would expect, because you get an added event but the content of the The normalization rules that you linked are not applied here because they are only valid when the changes are applied to the same URI, and it's not really the case here. |
It's clear. But i don't have an idea how we can reliably detect whether a.txt is ADDED or UPDATED. We don't know whether it existed before. I would say you should open an issue for nsfw as well. |
I don't think that nsfw should change its behaviour since it's just a wrapper around inotify (or similar tools) and inotify doesn't manage this case. I also think that a RENAME event in this case is more expressive and something that a developer may be expected to manage. Maybe splitting the RENAME event into the two events is the culprit here. |
We have to do it since LSP and vscode extensions don’t support renamed events. I can experiment with introducing renamed event in addition for Theia extensions. If they are reported reliably for all mv operations, it could work. Last time when I was implementing updating widgets based on file renaming it was not a case. Sometimes nsfw fails to deliver them at all or delivers add + remove events instead. |
Seems to be an issue in vscode as well: microsoft/vscode#30240 |
Description
When a file is updated, an event with type
FileChangeType.UPDATED
is fired, but when a file gets overwritten (for instance by amv
operation) what gets fired is only an event with typeFileChangeType.ADDED
. This means that when using the event emitteronFilesChanged
of the file watcher to check for updated files it's possible to miss a file change.Is this a known and expected behavior?
Reproduction Steps
To reproduce the issue it is possible to create a watcher on a file and overwrite it with a
mv
operation.OS and Theia version:
All the OSs.
Latest Theia version.
The text was updated successfully, but these errors were encountered: