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

[iCloud / other sync solutions ?] synced files firing the metadatacache change event #65

Closed tophee closed 1 year ago

tophee commented 1 year ago

I am sometimes getting long lists of notes that have supposedly been modified but which I definitely haven't touched in days or even weeks. I suspect that this may have something to do with icloud sync across devices.

Although I would not expect icloud to modify the modification date when notes are synced, I did notice that when I opened obsidian on my ipad (where I hadn't opened it for a while) it said "waiting for icloud sync to complete" (or something like that) and it counted down about 120 files that apparently weren't synced yet.

Now, the list of modified files is not 120 items long, so there is no immediate correspondence, but the 120 unsynced files will also have included plugin files and various settings that have changed over time, so I nevertheless suspect that the files that are now listed in my daily note as changed today were all included in that sync process on the ipad and that the plugin somehow picked them up as modified.

Long story short: if my suspicion above is correct, the algorithm that the plugin uses to check which files have been modified should probably be complemented to avoid such false positives.

If the above is wrong, what might explain those false positives (that more or less render the plugin useless)?

tophee commented 1 year ago

An additional thought: in my reasoning above I was assuming that the false positives were added to the daily note on my desktop computer, but it strikes me that the plugin also runs on the iPad and that it probably doesn't check file modified dates at all but has some other way of observing when files have changed (in real time, as it were). If this is so, then I would suspect that it started monitoring files before the initial sync was completed and thereby wrongly saw files changing "in front of its eyes" which were merely being synced.

If this is the case, a quick fix could be to just wait a minute or two before starting to monitor any changes.

That's not perfect, obviously, but would probably solve this problem in 99% of cases. To make it more robust overall, it might be a good idea to double check the "last modified" date on any notes before adding them to the list.

franciskafieh commented 1 year ago

observing when files have changed (in real time, as it were)

This. Modified dates are unreliable as many (if not all) sync solutions change them to the current date as they sync. The problem is that the cache change event is being fired for every synced file (I would assume.) I do not have access to iCloud, but I can maybe help you debug this later.

franciskafieh commented 1 year ago

hey @tophee, do you have discord by any chance? feel free to send it, and we can troubleshoot there. just for easier back and forth

tophee commented 1 year ago

@franciskafieh I have the discord app but I’m not sure what you want me to send.

How do you intended to troubleshoot this? Based on the above, I’d say that the first thing to try is to delay the monitoring at startup, no?

franciskafieh commented 1 year ago

@franciskafieh I have the discord app but I’m not sure what you want me to send. How do you intended to troubleshoot this?

I was going to send you a debug copy of the plugin to test for output, but it's alright. I don't need iCloud to reprod afaik, assuming the issue is that iCloud is pasting files into your vault.

I’d say that the first thing to try is to delay the monitoring at startup, no?

Wouldn't want to do this, as that set value could be insufficient if you're syncing a tonnn of files, and could be overkill if you're not syncing that many. More importantly, not everyone uses iCloud or even a sync solution at all. I'm sure there's a better solution I could look into

franciskafieh commented 1 year ago

Asked in the support discord, seems like syncing your vault before opening Obsidian is unfortunately the only way for now. image

Implementing a constant delay number would be a little bit too arbitrary. Closing this as wontfix because it is unfortunately an Obsidian x iCloud issue... Alternatively, you could disable OLM until your iCloud is synced up. If you think of any other solutions, feel free to let me know and re-open

franciskafieh commented 1 year ago

Also, if you would like, I could add a feature that checks against the modified date of the file. If the date is older than the current date, the file with not list as modified. If you think this might help, it would be good to make sure by checking the modified date property for newly synced iCloud files. I feel like the modified time would just be set to when it was last synced, but I'm not sure. Please send a screenshot if so!

tophee commented 1 year ago

Implementing a constant delay number would be a little bit too arbitrary.

Yes, just like implementing an arbitrary write interval would be. So why not make it a setting?

I could add a feature that checks against the modified date of the file. If the date is older than the current date, the file with not list as modified.

That totally makes sense. As you mentioned before, it won't help if the syncing service modifies the last modified date, but in that case, this safety net won't do any harm either.

I feel like the modified time would just be set to when it was last synced, but I'm not sure.

I would find that highly surprising and bad practice, but I'll keep an eye on it and let you know if this is what happens.

franciskafieh commented 1 year ago

The interval setting was implemented for 2 reasons mainly:

  1. Sync problems because of constant file writes (See #51)
  2. Performance on slower computers/higher note workflows due to constant file writes

implementing an arbitrary write interval

Thing is, no matter what your interval is set to, the modified files are certain to eventually be written to your log note. It's a lot less arbitrary because usually the user will rarely have to change this value after they first set it as they see fit. Doesn't matter, though, if the modified time solution works :arrow_down:

I would find that highly surprising and bad practice, but I'll keep an eye on it and let you know if this is what happens.

Yup, it's stupid, but that's one of the reasons I wrote this plugin in the first place lol. Take a look and let me know