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

How to reset all Sync data to get a clean whole store upload? #87

Open shadow2000 opened 11 years ago

shadow2000 commented 11 years ago

I'm experiencing a few problems after updating my CoreData model (Issue https://github.com/nothirst/TICoreDataSync/issues/86). Even if I delete the remote dropbox folder and remove the app from all device but the one with latest data and doing a "upload whole store", new device doesn't get this latest data.

Maybe its related to some change sets on the device which is uploading the latest data, so I'm wondering if it is possible the erase all remaining sync sets? After that the whole store upload should contain the content of the sqlite store?

@MrRooni What do you say?

shadow2000 commented 11 years ago

I'm asking to get a workaround for my users.

MrRooni commented 11 years ago

If you remove all the data from Dropbox you should be getting errors returned through the ApplicationSyncManagerDelegate and DocumentSyncManagerDelegate methods. Specifically, once your know that syncing has been set up, if you get a callback from:

- (void)applicationSyncManagerDidPauseRegistrationToAskWhetherToUseEncryptionForFirstTimeRegistration:(TICDSApplicationSyncManager *)applicationSyncManager

then you know that something has gone sideways on Dropbox.

Similarly you can handle remote file structure changes through these DocumentSyncManagerDelegate methods:


- (void)documentSyncManager:(TICDSDocumentSyncManager *)documentSyncManager didPauseRegistrationAsRemoteFileStructureDoesNotExistForDocumentWithIdentifier:(NSString *)anIdentifier description:(NSString *)aDescription userInfo:(NSDictionary *)userInfo;

- (void)documentSyncManager:(TICDSDocumentSyncManager *)documentSyncManager didPauseRegistrationAsRemoteFileStructureWasDeletedForDocumentWithIdentifier:(NSString *)anIdentifier description:(NSString *)aDescription userInfo:(NSDictionary *)userInfo;

- (void)documentSyncManager:(TICDSDocumentSyncManager *)documentSyncManager didFailToSynchronizeWithError:(NSError *)error;

For that last one just check if the error code is TICDSErrorCodeSynchronizationFailedBecauseIntegrityKeysDoNotMatch or TICDSErrorCodeSynchronizationFailedBecauseIntegrityKeyDirectoryIsMissing

Hope this helps!

shadow2000 commented 11 years ago

Hi,

I will check the callback methods you mentioned this evening to get a better feeling what's going wrong. But I do not know how I should do the reset of the sync setup as you suggested in #86

If you know that you've got the same data model on all your devices you should be able to reset your sync setup from one device and have all the other devices fall in line.

May you want to check the logs? http://time2feed.larsmeynberg.de/ressources/Device1FirstStartAfterDropBoxDeleted.txt http://time2feed.larsmeynberg.de/ressources/Device2FirstStartAfterUploadDevice1.txt

MrRooni commented 11 years ago

Assuming that your apps are properly handling the delegate methods I mentioned above, if you remove all the sync data from Dropbox and then push up a fresh baseline from one client, all your other clients should detect that the sync setup has changed and give the user appropriate options.

For instance, in MoneyWell, if we detect that the sync data on Dropbox has changed we let the user know and prompt them to setup syncing again. As they go through that process the sync setup classes that we've written handle allowing them to upload their document or download one that another user has posted.

shadow2000 commented 11 years ago

Ok if I delete the sync data from Dropbox will my App detect that via the mentioned delegate methods. But my problem is that even if the other devices are doing a download of the whole store they do not get the latest data. Do I have to call a cleanup method first? Maybe on the first uploading device before the upload gets started?

It even fails if I uninstall all copies of my App but from one device and delete the App-Folder on Dropbox. After deleting the Dropbox data the device detects that it have to upload the whole store but when I download this store on a fresh new device it is still some sync data missing.

MrRooni commented 11 years ago

It's possible that you're getting caught by some leftover files from a previous sync. You can stand up a temporary DocumentSyncManager to clean out the local files as well:

- (void)teardownLocalSetup
{
    NSError *fileCleanupError = nil;
    TICDSDocumentSyncManager *documentSyncManager = [[TICDSDocumentSyncManager alloc] init];
    [documentSyncManager removeLocalHelperFiles:&fileCleanupError];
    if (fileCleanupError != nil) {
        NSLog(@"%s %@", __PRETTY_FUNCTION__, fileCleanupError);
    }
}