franciskafieh / obsidian-list-modified

🪨 The advanced and adaptive changelog for Obsidian. Links all modified files meeting certain criteria to a timed (daily, weekly, monthly) note.
MIT License
85 stars 7 forks source link

[BUG] Beta 2.0.1 frequent rewriting list of files modified #51

Closed Triquetra closed 1 year ago

Triquetra commented 1 year ago

Describe the bug

As soon as any edit is made to a file, this version modifies the associated data.json, modifies the daily note by adding all files tracked in the data.json, then deletes all duplicates from the data.json (and, it seems, all files previously linked by 2.0). This happens so fast that it causes system slowdown and wreaks havoc on SyncThing, causing it to create a new conflict file every time both data.json and the daily note are changed.

This appears to be a regression. I don't experience this issue with 2.0

But since I noticed the writing (and subsequent deletion) of previously added links, it makes me wonder of this might be a solution to the other #issue. If the plugin added the pre-existing links under the specified header to the data.json, would it write new links for those files?

Expected behaviour

chill

Reproducing

My setup

Additional info?

This bug was experienced when I switched to my laptop from my desktop. When doing so, I noticed that 2.0.1 deleted the entire header block, including the header specified in this plugin, as well as previously linked files under that header.

franciskafieh commented 1 year ago

Hadn't tested this between devices and with sync, going to check this out tomorrow when I have time

franciskafieh commented 1 year ago

If the plugin added the pre-existing links under the specified header to the data.json, would it write new links for those files?

Yup! so users should no longer need to migrate. I'm wondering if I should set a delay between list updates. Thing is, afaik there is no way to run code when Obsidian shuts down. Only on plugin unload (i.e. the plugin gets updated or disabled.) This is going to be a tricky one to fix

franciskafieh commented 1 year ago

Just asked on the Discord: image

Do you think this could be a fix? I could keep the array in memory and only write it to disk every x minutes (set in plugin config.) Asking because I've never used syncthing.... Also, regarding the conflict files, is this related to #43? I was going to add a solution, but the guy never got back to me.

Triquetra commented 1 year ago

Yes, it could be related to issue 43, and adding your proposed regex exclusion would likely help. Though for 2.0.1, it seems to be more than that -- probably also the speed at which the daily note is updated. It seems that the note is updated while Syncthing is trying to sync it, creating conflicts because it's locked or after sync the file on the local computer is not the same as the one just synced.

The obsidian-git plugin has an activity delay that is user selectable. It causes git to not activate unless Obsidian has been inactive (no input) for a specified amount of time. That may be a good solution.

franciskafieh commented 1 year ago

Sorry for the delay. I've been pretty busy with other projects and IRL stuff recently. Hopefully I can get to this soon

franciskafieh commented 1 year ago

seems like even obsidian-git can't support save on close. https://github.com/denolehov/obsidian-git/issues/13

I guess i'll have to stick with the quit event for now. I'll also make a command to manually save.

i'll take a look at what they do for periodic save.

franciskafieh commented 1 year ago

Yes, it could be related to issue 43, and adding your proposed regex exclusion would likely help. Though for 2.0.1, it seems to be more than that -- probably also the speed at which the daily note is updated. It seems that the note is updated while Syncthing is trying to sync it, creating conflicts because it's locked or after sync the file on the local computer is not the same as the one just synced.

The obsidian-git plugin has an activity delay that is user selectable. It causes git to not activate unless Obsidian has been inactive (no input) for a specified amount of time. That may be a good solution.

Going to make this a contains instead of regex. Will be less confusing.

EDIT: started adding configurable delay and contains ignore locally. Going to close.

franciskafieh commented 1 year ago

@Triquetra both ignore words and interval saves are added in release 2.0.2