-
Notifications
You must be signed in to change notification settings - Fork 34
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
Modification events are lost depending on editor - how the file is written - neovim #88
Comments
I think the main issue is the The exception happens when we do: pathMap.subMap(treeRoot, Paths.get(treeRoot.toString(), "" + Character.MAX_VALUE)); The LANG=C.UTF-8
LC_ALL=C.UTF-8 In any case, I'm not sure we should be relying on the |
LANG=en_GB.utf8
LC_ALL=
I tried setting LANG and LC_ALL to C.UTF-8 (exported in the shell before
starting the JVM) but this did not change the behaviour.
On my system Character.MAX_VALUE printed in my repl as \<00ffff>
openjdk 19.0.2 2023-01-17
(I had no idea about LANG and LC_ALL - that looks like a deep rabbit hole)
…On Wed, 1 Feb 2023 at 20:55, Greg Methvin ***@***.***> wrote:
I think the main issue is the InvalidPathException. That prevents us from
being able to notify for the ENTRY_DELETE and remove the hashes from the
hash map. Then when we get an ENTRY_CREATE event, we ignore it because we
see it as a "duplicate" create event since the file already exists.
The exception happens when we do:
pathMap.subMap(treeRoot, Paths.get(treeRoot.toString(), "" + Character.MAX_VALUE));
The Character.MAX_VALUE is used as a hack there to get us all the paths
in the subdirectory that start with that particular path. This code
basically assumes your system charset is UTF-8, so that character should be
representable. Is it possible you're using some other charset? I think you
should be able to force UTF-8 everywhere by setting the environment
variables like:
LANG=C.UTF-8LC_ALL=C.UTF-8
In any case, I'm not sure we should be relying on the subMap hack above,
so perhaps an alternative solution makes sense there anyway.
—
Reply to this email directly, view it on GitHub
<#88 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFPR4XI3Z7O6KJBKOZZZCTWVIXHZANCNFSM6AAAAAAUNL3QYM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
ok, it's probably not worth trying to debug why that specific hack doesn't work. It's easy enough to switch to another method of getting the paths in a subtree. |
@davesann try version I believe you should get a |
Using nvim Yes. I think this has fixed the issue. with backupcopy=yes; (copy and modify in place); still works as before; I get:
with backupcopy=no; (rename and create new); works, I get:
The final entry_modify is not converted to a Modify event - which I think is expected using xed This was just out of curiosity (I don't use xed but tried it when first looking at the issue) - no exceptions. Xed seems to use a tmp file - but this does not appear to generate the final create or modify event for the modified file - so this change does not get notified.
|
Interesting... so with xed it appears from the logs that we get an If it's the latter, then the I suppose it might not hurt to just report a |
So after looking at this a bit more, I realize there's a good reason directory-watcher suppresses the duplicate Basically, when a new directory is created, there several situations in which we don't get That said, while it's a bad idea to send a duplicate |
I came a situation where notifications are lost (I think because here: https://github.com/gmethvin/directory-watcher/blob/main/core/src/main/java/io/methvin/watcher/DirectoryWatcher.java#L347) the has is not seen as new.
This appears to arise from the manner in which an editor writes the files. I was using neovim.
I don't know if you will fix this - but the issue may be useful to others
neovim has a couple of ways that it writes when handling backups - the filewatcher will fail if backupcopy=no (or "auto" because then it is sometimes "no")
from neovim help
I also saw this swallowing of events also with xed - probably for similar-ish reasons. And not with nano.
There are exceptions in the stack trace for these file changes that might help diagnose:
This is with neovim
Failing case; backupcopy=no; Final ENTRY_MODIFY is swallowed
Successful case; backupcopy=yes; ENTRY_MODIFY is sent as MODIFY event.
The text was updated successfully, but these errors were encountered: