@@ -461,7 +461,10 @@ public class ParseRemote: OCKRemoteSynchronizable {
461
461
// Push all revision records
462
462
ParseRemote . queue. async {
463
463
Task {
464
- let logicalClock = deviceKnowledge. clock ( for: self . uuid)
464
+ var updatedDeviceKnowledge = deviceKnowledge
465
+ // Increment and merge Knowledge Vector
466
+ updatedDeviceKnowledge. increment ( clockFor: self . uuid)
467
+ let logicalClock = updatedDeviceKnowledge. clock ( for: self . uuid)
465
468
self . notifyRevisionProgress ( 0 ,
466
469
totalRecords: deviceRevisions. count)
467
470
@@ -477,7 +480,7 @@ public class ParseRemote: OCKRemoteSynchronizable {
477
480
if index == ( deviceRevisions. count - 1 ) {
478
481
self . finishedRevisions ( parseClock: parseClock,
479
482
cloudVector: cloudVector,
480
- localClock: deviceKnowledge ,
483
+ localClock: updatedDeviceKnowledge ,
481
484
completion: completion)
482
485
}
483
486
} catch {
@@ -509,17 +512,13 @@ public class ParseRemote: OCKRemoteSynchronizable {
509
512
}
510
513
}
511
514
512
- func finishedRevisions( _ shouldIncrementCloudClock : Bool = true ,
515
+ func finishedRevisions( _ incrementedCloudClock : Bool = true ,
513
516
parseClock: PCKClock ,
514
517
cloudVector: OCKRevisionRecord . KnowledgeVector ,
515
518
localClock: OCKRevisionRecord . KnowledgeVector ,
516
519
completion: @escaping ( Error ? ) -> Void ) {
517
520
Task {
518
521
var updatedCloudVector = cloudVector
519
- if shouldIncrementCloudClock {
520
- // Increment and merge Knowledge Vector
521
- updatedCloudVector. increment ( clockFor: self . uuid)
522
- }
523
522
updatedCloudVector. merge ( with: localClock)
524
523
525
524
guard let updatedClock = PCKClock . encodeVector ( updatedCloudVector, for: parseClock) else {
@@ -529,8 +528,8 @@ public class ParseRemote: OCKRemoteSynchronizable {
529
528
}
530
529
531
530
// If clocks incremented or new clock introduced, no need to save to Cloud.
532
- guard shouldIncrementCloudClock ||
533
- ( !shouldIncrementCloudClock && cloudVector. uuids. count != updatedCloudVector. uuids. count) else {
531
+ guard incrementedCloudClock ||
532
+ ( !incrementedCloudClock && cloudVector. uuids. count != updatedCloudVector. uuids. count) else {
534
533
await self . remoteStatus. setNotSynchronzing ( )
535
534
// Clocks not updated, no need to update cloud.
536
535
if #available( iOS 14 . 0 , watchOS 7 . 0 , * ) {
0 commit comments