drewmccormack / ensembles

A synchronization framework for Core Data.
MIT License
1.63k stars 131 forks source link

v2.0.3 and CDEICloudFileSystemDidDownloadFilesNotifications #189

Closed asciiz closed 9 years ago

asciiz commented 9 years ago

I am starting in a clean-slate state, with a single store and no other registered devices.

While and shortly after syncing, I am getting several CDEICloudFileSystemDidDownloadFilesNotifications. Because I invoke a merge each time I get this notification, I am merging unnecessarily.

I thought this notification would only fire if data from other devices/stores are downloaded.

drewmccormack commented 9 years ago

Yes, but it is not perfect, because it does not know if other data is still coming. There is a timer delay to try to give the system a bit more time, but there is no foolproof way to know if another batch of files is coming very soon.

asciiz commented 9 years ago

Perhaps Ensembles could just ignore files created on the same device for the same store instead sending notifications for those files?

drewmccormack commented 9 years ago

It does ignore local files.

The problem is that iCloud sometimes downloads a few files at a time. Ensembles sees that there are no more files to download in the ones it knows about, and fires the notif, but actually there are more files coming. I don't know why iCloud doesn't include all files at once, but it doesn't.

So you merge, but there are missing files, and it gives an error.

It's no big problem though. Just try again, and it will work when all the files are there.

asciiz commented 9 years ago

But it seems that Ensembles starts firing notifications if any files are written to the "Mobile Documents..." folder.

For example:

or

Because there are no other stores, every file written belongs to the local store and nothing has been downloaded from other devices.

I don’t understand why I am getting notifications, even if there are no other stores and the files has just been written by Ensembles for the local (and only) store.

In 2.0.0, it works as expected.

drewmccormack commented 9 years ago

Ah, I think I know what is happening. I now included the NSFilePresenter to monitor changes to the folder. This seems to be more robust in general.

I will add an issue to see if I can ignore any local changes.

Thanks for reporting it.

Drew

On 19 Sep 2014, at 12:14, asciiz notifications@github.com wrote:

But it seems that Ensembles starts firing notifications if any files are written to the "Mobile Documents..." folder.

For example:

initial leeching/merging (clean-slate) Ensembles writes a baseline/store file to „Mobile Documents…“ I am getting notifications for the files written or

start merging Ensembles eg. writes a .cdeevent to „Mobile Documents…“ I am getting a notification for the file(s) written Because there are no other stores, every file written belongs to the local store and nothing has been downloaded from other devices.

I don’t understand why I am getting notifications, even if there are no other stores and the files has just been written by Ensembles for the local (and only) store.

In 2.0.0, it works as expected.

— Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/189#issuecomment-56159817.

drewmccormack commented 9 years ago

I have pushed a fix for this. If you have access, you can download the master. If not, get in touch with me at drewmccormack@mac.com to request a new binary to test.

asciiz commented 9 years ago

Still the same issue with the new binary, unfortunately.

asciiz commented 9 years ago

The latest binary works fine. It seems that I don't get notifications for local files anymore.

However, I've noticed the following while testing:

So, I am usually merging several times for a single change on A. I think I am getting multiple notifications due to the strange iCloud download behavior you mentioned. BTW, this often causes an "NSCocoaDomainError: 4, no such file" error. On 10.9.5, this is followed by an CDEErrorCodeDiscontinuousRevisions or CDEErrorCodeMissingDependencies error. On 10.8.5, I am only getting the NSCocoaDomainError.

drewmccormack commented 9 years ago

To be honest, it’s not a very serious problem, because merge errors happen all the time, for all sorts of reasons. And usually they happen fast, so they shouldn’t waste much CPU time.

It may be caused by iCloud bursting the metadata notifications, but if you want to look further to see if we can somehow reduce the issue, I am happy to give you access to the source code, and a bit of guidance on where to look.

It would probably be easier for you than me, because you are the one experiencing the problem.

Drew

On 21 Sep 2014, at 17:18, asciiz notifications@github.com wrote:

The latest binary works fine. It seems that I don't get notifications for local files anymore.

However, I've noticed the following while testing: 1.

delete object on A merge A 2.

getting notification on B merging B Immediately after merging B, I am getting at least one more notification on B and merging B repeats.

getting notification on A merging A Immediately after merging A, I am getting more notifications on A and merging A repeats. So, I am usually merging several times for a single change on A and B. I think I am getting multiple notifications due to the strange iCloud download behavior you mentioned. BTW, this often causes an "NSCocoaDomainError: 4, no such file" error. On 10.9.5, this is followed by an CDEErrorCodeDiscontinuousRevisions or CDEErrorCodeMissingDependencies error. On 10.8.5, I am only getting the NSCocoaDomainError.

— Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/189#issuecomment-56301859.

asciiz commented 9 years ago

I've tested again with 2.0.0 and this version works completely different. I am using the same environment.

I am also don't get any errors so far. It seems that 2.0.0 fires this notification only if the complete set has been download (eg. 1-7 of baselines). In 2.0.3, the notification fires as soon as one file of the set has been downloaded (eg. 3), which produces an error for the missing (not yet downloaded) files if I am trying to merge.