vdirsyncer
vdirsyncer copied to clipboard
Retry PUT 409 errors - delete and re-create event
Attempt to address #963
I would appreciate a code review here - there might be a more elegant way to address this problem, but it works for my (very limited) use case.
@WhyNotHugo Thanks for your comments. I agree that I need to figure out how to make these changes more correct before merging, but I don't understand CalDAV or the code well enough to know what I need to do. These hacks are just what I need to get the sync in my configuration working.
A few tests are stil failing: https://builds.sr.ht/~whynothugo/job/776820#task-test-134
any updates on this?
Basically each time that vdirsyncer reads an event, we also get an Etag, which can be though of as a version identifier. The Etag for an event changes each time that its content changes. When vdirsyncer tries to delete or alter an event, it specifies "only if the Etag is equal to XXX". This avoids deleting an event if someone else has modified it after vdirsyncer last read it.
A 409 error means that we tried a write operation on an event assuming it had not changed, but it has changed. If this keeps happening over and over, it likely means that there is an issue elsewhere in the logic. But in the general case, ignoring a 409 error means that you're overwriting or deleting files which have been modified by someone else, and will result in a data loss.
I honestly haven't looked deeply into the cause of this bug because it sounds very non-trivial, and I'd rather focus energy on the rewrite which should either not have this bug, or be a lot easier to debug.