Weird behavior with a script and iCloud

I’m using Obsidian with Mac, iPhone and iPad, and storing its Vault in iCloud.

This solution, using Shortcuts and Scriptable, “just” appends a short note to a Daily Notes file. It seems to usually work, but sometimes it creates additional/duplicate files in iCloud with a number in the end of file name.

Does someone know if this kind of behavior is iCloud to blame? Or how could I find reason why this sometimes happens?

My best guess would be that your iCloud is out of sync on those occasions.

Let’s say your last “global” update that has synced across devices is A. Next on your Mac, you update B, and this is synced up to the cloud (A-B).

Now on your iPhone, you run the automation to make update C, only update B has not yet found its way down to the iPhone. Normally it would have, but for some reason (connectivity, background process utilisation, etc.) this time, it has not. This latest, out of step update is then synced up to the cloud (A-C).

At this point, iCloud is perhaps able to get a bit clever and note from sync timestamps/positions that there is in effect a potential conflict. Rather than overwriting (A-B with A-C), it places two copies in the directory (A-B & A-C), with a sequence number, so that you can manually resolve it.

As I say, this is just a guess. Without some examples, timings, and precise sequences it is hard to tell if this is a viable explanation for your particular observations, or just a viable explanation for the more general observations described.

1 Like

Thank you @sylumer!

That might well explain this behaviour.

I guess there is very little visibility to iCloud sync process in general.