nothirst / TICoreDataSync

Automatic synchronization for Core Data apps, between any combination of Mac OS X and iOS: Mac to iPhone to iPad to iPod touch and back again.
https://github.com/nothirst/TICoreDataSync/wiki
807 stars 61 forks source link

continueSynchronizationByResolvingConflictWithResolutionType: picks the wrong operation to resolve the conflict #28

Closed chbeer closed 11 years ago

chbeer commented 11 years ago

This method

- (void)continueSynchronizationByResolvingConflictWithResolutionType:(TICDSSyncConflictResolutionType)aType
{
    TICDSSynchronizationOperation *operation = [[self.synchronizationQueue operations] lastObject];

    [operation setMostRecentConflictResolutionType:aType];

    [operation setPaused:NO];
}

picks the lastObject to solve the conflict. But looking at the operation, it seems it's the wrong one (breakpoint on second line in method):

(lldb) print [operation isPaused]
(BOOL) $4 = NO
(lldb) po [[self.synchronizationQueue operations] valueForKeyPath:@"isPaused"]
(id) $6 = 0x208c7fb0 <__NSArrayI 0x208c7fb0>(
1,
0
)

This shows, the first operation is paused, not the second one.

In my case there seem to be two syncing operations (maybe that's the problem?) and the wrong one gets unpaused.

MrRooni commented 11 years ago

Thanks for the report Christian. We actually prevent more than one synchronization operation from running at once which why we haven't seen this problem yet, but it's something that should be fixed.

chbeer commented 11 years ago

I didn't have the time to create a pull request. I fixed it like this:

- (void)continueSynchronizationByResolvingConflictWithResolutionType:(TICDSSyncConflictResolutionType)aType
{
    if ([self.synchronizationQueue operations].count == 0) return;
    TICDSSynchronizationOperation *operation = [[self.synchronizationQueue operations] objectAtIndex:0];

    [operation setMostRecentConflictResolutionType:aType];

    [operation setPaused:NO];
}
MrRooni commented 11 years ago

Thanks Christian, I've merged that change in.