beaussan / update-time-on-edit-obsidian

MIT License
165 stars 15 forks source link

Lots of "note" has been modified externally, merging changes automatically when update-time-on-edit enabled. #53

Open chigh opened 1 year ago

chigh commented 1 year ago

I don't know if this is something that's happening with the insider version of Obsidian (1.4.2) or the update-time-on-edit plugin (version 2.0.2), but I've been getting lots of the following messages.

"Note title" has been modified externally, merging changes automatically.
Screen Shot 2023-08-03 at 18 19 25

Sometimes the messages come one right after another. Sometimes, it will start immediately upon typing in a note, and other times, it doesn't for a brief period of time. I noticed the plugin no longer has the setting in the Obsidian interface to change the time between updating and is updating almost immediately after and during typing in a note. There is a setting in the data.json file, and it's set to one minute, but the plugin doesn't wait one minute to update the notes.

  "minMinutesBetweenSaves": 1,

When I disable the plugin, these messages stop. I have a number of other plugins enabled. I could disable them all and try again, but none of them update notes like this one does, and I really like/want what this one does.

https://github.com/beaussan/update-time-on-edit-obsidian/assets/4204038/a24077ce-f3dc-499e-b684-d36a460f2719

opensolutionsgroup commented 1 year ago

I am on Obsidian 1.37 and noticed a similar issue with 2.02. I never had a issue previously with Update Time on Edit. I noticed the issue when some files that I was editing would suddenly erase keypresses that I just had made a few seconds earlier. I noticed a lot of sync activity going on with the last few tiles I edited. I also noticed that the time kept incrementing every 10 seconds in front matter and it would of course sync that change. The file just kept going around and around. I use Obsidian Sync and was testing with 3 computers in front of me.

I disabled the plug-in and the syncing resolved itself. Hope this helps.

beaussan commented 1 year ago

Hi, first of all, thanks for raising this issue !

I noticed the plugin no longer has the setting in the Obsidian interface to change the time between updating and is updating almost immediately after and during typing in a note. There is a setting in the data.json file, and it's set to one minute, but the plugin doesn't wait one minute to update the notes.

Yes, I removed this option with the new v2 approach, but I am going to rollback this, while changing the way it behaved. This should also temorrary fix the issue about the sync

I also noticed that the time kept incrementing every 10 seconds in front matter and it would of course sync that change. The file just kept going around and around. I use Obsidian Sync and was testing with 3 computers in front of me.

This is a limitation currently of Obsidian api that should be fixed soon (according to this github issue) ! TLDR: this plugin relies on mtime (modification time) from filesystem & obsidian, however, the current api don't allow to update such time to the previous one while editing the frontmatter, and thus, causing a sync with a new ctime; causing the second computer to update the header again, etc.

chigh commented 1 year ago

Thanks for the response!

beaussan commented 1 year ago

v2.1.0 added back the minMinutesBetweenSaves setting in a new way, this should address the sync issue.

In the meanwhile we have the proper api from Obsidian to ensure mtime is not modified, you can increase the delay between updates ! :tada:

Here is the TLDR of how it works :

graph TD
I{File changed} --> A
A{"Update header already present?"} -->|No| U{Update header with mtime}
A --> |Yes| C{Read update value. Is it enough passed since last update ?}
C --> |Yes| U
C --> |No| E{Do nothing}
U
chigh commented 1 year ago

Thank you!

beaussan commented 1 year ago

This should be way better with the newer version, https://github.com/beaussan/update-time-on-edit-obsidian/releases/tag/2.3.0 ! This plugin no longer edit the file's creation & modification time

beaussan commented 1 year ago

Two things were done to improve this futher :