Cirrus
Cirrus copied to clipboard
Allow limit exceeded errors to be retried
The current implementation of retryCloudKitOperationIfPossible() only performs a retry if a value for retryAfterSeconds is present. However, 'limit exceeded' errors by CloudKit do not include a value for retryAfterSeconds (see Apple documentation). This caused retries of limit exceeded errors not to be performed. Because the entries remain 'cached' in the upload/delete buffer, this also effectively prevents any further uploads/deletions as Cirrus tries to bundle any other updates with the ones still in the buffer.
This fixes that by using a default delay of 0 for limit exceeded errors.
An alternative solution would be to not use retryCloudKitOperationIfPossible() at all, and simply directly perform the chunked requests. It might be a bit cleaner, at the loss of some logging (and there's a possibility that Apple in the future will include a value for retryAfterSeconds'for these errors).