Application detects external change to note only if the timestamp of that file changes.
Application incorrectly detect updates to current note while it is being edited. When I am editing a note, the cursor is constantly jumping and I am constantly receiving dialog messages indicating that the note has been changed externally.
As best I can determine, whenever the current note gets saved, within a few minutes the Nextcloud desktop client synchronizes it with the server and writes metadata to the base directory in files beginning with ._sinc. The application detects the change to the directory, which somehow causes it to try to reload the file from disk, reporting the following in the Log panel: [<timestamp>] [status] Loading external changes <filename>.md.
So two events are occurring that ought need to examined:
In my deployment, it is sufficient simply to open a note and to type for no more than a minute, with the Nextcloud desktop client operating on the same directory.
[05:35:50] [status] Stored current note to disk
[05:35:54] [status] Notes directory was modified externally
[05:35:54] [status] Stored 1 note(s) to disk
[05:35:58] [status] Notes directory was modified externally
[05:35:58] [status] Stored 1 note(s) to disk
[05:36:01] [status] Stored 1 note(s) to disk
[05:36:02] [status] Notes directory was modified externally
[05:36:02] [status] Stored 1 note(s) to disk
[05:36:05] [status] Notes directory was modified externally
[05:36:05] [status] Stored 1 note(s) to disk
[05:36:09] [status] Notes directory was modified externally
[05:36:21] [status] Stored 1 note(s) to disk
[05:36:24] [status] Notes directory was modified externally
[05:36:24] [status] Stored 1 note(s) to disk
[05:36:25] [status] Current note was modified externally
[05:36:27] [status] Loading external changes from: foo note.md
[05:36:27] [warning] QTextCursor::setPosition: Position '153' out of range
[05:36:28] [status] Notes directory was modified externally
[05:36:28] [status] Stored 1 note(s) to disk
[05:36:31] [status] Notes directory was modified externally
[05:37:26] [status] Notes directory was modified externally
Please don't post the text dumps in files, that make them hard to read. ;) And please post "Output from the debug section in the settings dialog", or it's hard to tell what we are talking about.
This is an issue often discussed here and basically can't be fixed (at least I'm not aware of a way). It depends a lot on operating systems, how many files are open by other applications and so on. You only get inotify notifications for files (that you have to add to the notifier) and directories (where you will get notified by every change in it but don't know which file was changed).
Are there any new insights I don't know of?
this is the Qt implementation: http://doc.qt.io/qt-5/qfilesystemwatcher.html
Sorry that I misunderstood the issue template. Also, sorry for posting a duplicate, as I searched beforehand, but the issues I found were all closed.
Regarding the issue, it would surely be disappointing if you correctly say that the issue cannot be fixed, because I am finding that when the open document regresses, and the cursor jumps, the application becomes completely unusable, as I am sure you would understand.
At the same time, I must admit to being confused by your conclusion. We have in front of us, at minimum, two facts that are plain:
Then, if all else fails, at a bare minimum, the application can test the modification timestamp, and possibly even the file body, and compare against internally saved data, before reloading the file or generating a message for the user. If the application finds that data on the file system matches the internally saved data, then it should be clear, I think, that the application should suppress reloading the file.
Meanwhile, although the above can serve as a fallback, an existence proof, if you like, that the issue can be resolved, I would notice that any of a variety of strategies can be imagined for monitoring directory changes.
Using the existing approach of the QFileSystemWatcher, a wrapper for inotify, I can make two observations:
My view, then, is that a variety of possible solutions are available, some that may entail redesign, and surely others that do not.
I would have to review more comments from you to understand what I may be overlooking, that causes you to conclude that the issue cannot possibly be resolved.
My very short answer to your essay (:smile:) is: I'm open to pull requests if anyone can improve on any of the the situations (which I would love to), without introducing regressions. I already tried quite some different things.
In addition (like mentioned in other issues): If anyone is hit by the situation of jumping mouse cursors (macOS seems prone to that), there is an option in the General settings to turn off the cursor restoring. There also is an option to turn off detection of external changes altogether.
It's possible that sometime in the future it would be feasible for me become familiar with your codebase and try to make some enhancements that you could consider pulling.
Is the immediate obstacle, for you, to find the time to commit to the work, or to find the way to make the application work better?
Beside finding a system where your problems occur (you still failed to even failed to use the issue helper dialog or the Debug section of the settings to provide information about your setup 馃槈) and spending the time finding out where they come from it will be hard to find a way around them. I already spent a huge amount of time making it as stable at it is for most of the users. But feel free to play around, this is a good entry-point: https://github.com/pbek/QOwnNotes/blob/develop/src/mainwindow.cpp#L874
I understand. I updated the report to include the requested information. (I had misunderstood earlier that you already knew how to reproduce.)
I updated the report to include the requested information.
Please open the QOwnNotes Settings and click on the Debug Item in the settings menu tree. Then you will see what I'm talking about. The issue generator in the Help Main Menu does that automatically.
But feel free to play around
Happy hunting. https://www.qownnotes.org/installation#building will help you
Right. I must have pressed "preview", but forgotten to submit. See update.
great (beside still not posting the output inline :laughing:), just tell me if you can find something out or you need help with the code
I will close this until there is more information.
Most helpful comment
Right. I must have pressed "preview", but forgotten to submit. See update.