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] When Obsidian indexes synced files, they are marked as modified #91

Open MMoMM-org opened 4 months ago

MMoMM-org commented 4 months ago

Problem Statement:

  1. I'm using different sync mechanism for different vaults. (Box, iDrive, ObsidianSync)
  2. I'm not running Obsidian all the time on all devices (Dual Boot)
  3. Sometimes Obsidians "forgets" the vault exists or things it needs to re-index it.
  4. Both 2. and 3. trigger a massive number of updated notes for that day

Example: I did use my Work Obsidian (which is syncing via BOX but that isn't the real issue) for 2 weeks on my work laptop. After that I shut it down. I than wait for Box to stop syncing on my work PC. I start Obsidian. Now there are 2 options of what will happen. Either 2. or 3. from above. If 2.

I think there could be 3 ways to remove the problem. For Issue 2.

franciskafieh commented 4 months ago

Took a quick look at the plugin you linked. The method OLM uses to track files is the same. Outside modifications and sync stuff should not be tracked unless Obsidian is open before the files are synced. OLM also does not track files based on their modification dates.

Is there any way you can get your files to sync before you open Obsidian? If so, could you try this and let me know if it resolves your issue?

Make sure that a flag which is synced by all Sync Services (at least filebased and Obsidian Sync) is used as a starting point for which files are changed

Not sure what you mean here. Could you expand on this please?

MMoMM-org commented 4 months ago

That is weird as I know it will think that notes are updated if you use OneDrive etc as sync service. Also I can't let the notes sync before as I'm also using Obsidian Sync, that only runs if Obsidian is running.

To me it looks like that OLM tracks somewhere the last time it was run. And this information is not synced to other instances, neither with OneDrive etc nor with Obsidian Sync.

I think that this is the case because if I work on my computer and turn it off, then use my laptop for 2 weeks, then switch off the laptop, turn on the compter, OLM on the computer instance will find all the notes which were created during those 2 weeks as modified / new. Keep in mind that OLM is running also on the laptop during that time.

MMoMM-org commented 3 months ago

It just came to my mind. Could it be that this is a "feature"/bug in Obsidian? Indexing shouldn't cause a modified event. So if Obsidian fires a modified event every time it sees new files (either before or after Obsidian starts) or when it reindexs the vault, the result of OLM would make sense. It would also explain the behaviour I see. Update Time on Edit probably doesn't has the issue as it only works in the note you have open. What do you think?

franciskafieh commented 3 months ago

Could it be that this is a "feature"/bug in Obsidian? Indexing shouldn't cause a modified event. So if Obsidian fires a modified event every time it sees new files (either before or after Obsidian starts) or when it reindexs the vault

I believe this is true but I would need to test further. It's weird that you're the first person opening an issue on this, though, with all the people that use this plugin with Obsidian sync. I will need to look into it further in the next coming weeks. I am very busy at the moment

ChrisKolan commented 2 months ago

I can confirm this problem. This happens every time indexing is activated. I use Syncthing to synchronize my notes between machines.

franciskafieh commented 2 months ago

Sorry for the late reply, I have been very busy lately.

As I mentioned before:

Is there any way you can get your files to sync before you open Obsidian? If so, could you try this and let me know if it resolves your issue?

Otherwise, I am currently unsure how to solve this. The Obsidian API is very limited in terms of listening to changes. There is no way to tell whether a file is modified/created/deleted by user vs the sync service or another program. Since Obsidian List Modified only tracks changes made while it is open, the only way is to disable OLM/keep Obsidian closed until files are synced.

franciskafieh commented 2 months ago

One possible solution could be a setting to disable OLM to by default, until you manually turn it on from settings. This could be done automatically if there is a way to tell when SyncThing, same for any other sync service

ChrisKolan commented 2 months ago

When I use Syncthing, the files are always synchronized, before I open Obsidian, I always check that this is the case. So I think there is some other effect at play here. As I mentioned, the problem occurs during indexing. I don't know exactly what triggers the indexing, but I have noticed that the indexing occurs when one of the computers has been switched off for a long time. The longer it has been off, the longer the indexing and also the longer list of the the changes in OLM.

MMoMM-org commented 2 months ago

Perhaps adding a configurable delay could help? I know that this will not cover all cases but might be an option. Or allow editing of the list OLM creates, atm it is quite stubborn and I need to edit the list the day after.

franciskafieh commented 2 months ago

I just had an idea that would probably cover most cases. If more than 5 files are added at once, it won’t track all files modified with a few seconds until they are edited again. I think this would be a good idea, and I would make it toggleable.

Being able the edit the list is a feature I would work on eventually, but I haven’t even had time recently to work on core bug fixes. School has been super busy lately

On Fri, Apr 26, 2024 at 4:50 AM Marcus Breiden @.***> wrote:

Perhaps adding a configurable delay could help? I know that this will not cover all cases but might be an option. Or allow editing of the list OLM creates, atm it is quite stubborn and I need to edit the list the day after.

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/91#issuecomment-2078933763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZU3WZDG6GK6INAXACLY7IILRAVCNFSM6AAAAABD7Y5772VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZYHEZTGNZWGM . You are receiving this because you commented.Message ID: @.***>

ChrisKolan commented 2 months ago

As @MMoMM-org mentioned "Perhaps adding a configurable delay could help?". This could potentially solve the problem. When obsidian starts up and indexes, OLM should be turned off and on after some time.

franciskafieh commented 2 months ago

works for me. that’s an easier solution than what I proposed anyway

On Mon, Apr 29, 2024 at 3:49 PM Chris Kolan @.***> wrote:

As @MMoMM-org https://github.com/MMoMM-org mentioned "Perhaps adding a configurable delay could help?". This could potentially solve the problem. When obsidian starts up and indexes, OLM should be turned off and on after some time.

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/91#issuecomment-2083537063, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZUN4Y4TP7ZFLBFBUNLY72P4VAVCNFSM6AAAAABD7Y5772VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGUZTOMBWGM . You are receiving this because you commented.Message ID: @.***>

franciskafieh commented 1 week ago

Waiting for advice from Obsidian staff as to how a delay could be properly configured.

franciskafieh commented 1 week ago

image note to self: possible fix that would not require the bandaid solution of a delay period...

Once 3.0 is released in beta, I will let you all know and you can see if it fixes the issue.

The latter solution would be better as it would still allow for the most recent cache to be used.

can putting it in onLayoutReady help?

franciskafieh commented 6 days ago

Nevermind. All is well. The current solution uses the file's system modification time. As long as Obsidian is not opened until all files are synced, this solution should be sufficient. Does this sound fair?

Basically, when a file is created/changed outside of Obsidian, Obsidian needs to update its cache. Checking the file's modification time will ensure that if a file has not been modified within a set time period (I will say 1 second for now), OLM should not list it.