Theia: nsfw does not always report ADDED/DELETED events on linux

Created on 13 Aug 2018  路  11Comments  路  Source: eclipse-theia/theia

To reproduce, try to create or delete a file in src folder for any Theia extension. You will see that the navigator does not get an event.

Strangely when a file is moved or its content is changed events are reported always. It would be interesting to investigate what is the cause of this difference in nsfw and our use of Node.js fs API.

OLinux bug filesystem

All 11 comments

@elaihau @marcdumais-work was not it address as well by recent changes in nsfw? It would be good to file an issue about it while the project is active.

I couldn't reproduce this issue from the master branch
I tested both file creation and deletion.
btw the testing was performed on Ubuntu + Chrome

peek 2019-01-23 08-55

You should first expand and then do changes. Otherwise nodes fetched on a node click. You should see file changes in the navigator without touching it at all.

You are right
peek 2019-01-23 09-23

I found nsfw did call our event callback on file added to theia/packages/monaco.
We have this bug because the event from nsfw was associated with a different path theia/node_modules/@theia/monaco which is the symbolic link of theia/packages/monaco.

any changes made to theia or theia/packages were associated with the correct paths, because there were no links for them in the workspace.

when file edits happened in theia/packages/monaco, however, nsfw emited two events, one associated with theia/node_modules/@theia/monaco, and the other theia/packages/monaco.

While this is something that needs to be fixed in nsfw, there is a way to work around this issue in theia:


(events: nsfw.ChangeEvent[]) => {
            for (const event of events) {
                const path = paths.join(event.directory, event.file!);
                if (event.action === nsfw.actions.CREATED || event.action === nsfw.actions.DELETED) {
                    this.getAffectedFiles(path, [ ]).forEach(file => {
                        if (event.action === nsfw.actions.CREATED) {
                            this.pushAdded(watcherId, path);
                        }
                        if (event.action === nsfw.actions.DELETED) {
                            this.pushDeleted(watcherId, path);
                        }                     
                    });
                }

                if (event.action === nsfw.actions.MODIFIED) {
                    this.pushUpdated(watcherId, path);
                }
                if (event.action === nsfw.actions.RENAMED) {
                    this.pushDeleted(watcherId, path);
                    this.pushAdded(watcherId, path);
                }
            }
        }
private getAffectedFiles(path: string, affectedFiles: string[]): string[] {
    // find all affected files recursively. in each call, we could
    // use fs.lstat to check if it is a symlink
    // and use fs.readlink to get the target

}

What do you think? @akosyakov

@elaihau i would start by filing an issue for nsfw, maybe it would be resolved fast and then we don't need any work arounds. Could you open such and link to this issue?

@elaihau just to confirm your suggestion is to resolve a symlink to a real path and if it is different then report an event for a real path as well?

just to confirm your suggestion is to resolve a symlink to a real path and if it is different then report an event for a real path as well?

yes exactly.

@elaihau i would give it a try, at least it should improve a situation for real paths, won't report events for all symlinks to this path though :(

won't report events for all symlinks to this path though :(

discussed with @svenefftinge that it is fine for now, we will wait till one opens a real issue for it

Was this page helpful?
0 / 5 - 0 ratings