Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iCloud] Not finding remote file structure on first run #69

Open
agrigg opened this issue Jul 5, 2013 · 4 comments
Open

[iCloud] Not finding remote file structure on first run #69

agrigg opened this issue Jul 5, 2013 · 4 comments

Comments

@agrigg
Copy link

agrigg commented Jul 5, 2013

When using the iCloud sync manager, it is not finding the remote file structure, even though it exists and so the delegate method didPauseRegistrationAsRemoteFileStructureDoesNotExistForDocumentWithIdentifier is being called. It looks like in the checkWhetherRemoteGlobalAppDirectoryExists method in TICDSiCloudBasedApplicationRegistrationOperation, it is just doing a simple fileExistsAtPath call. It looks like iCloud has the files, but hasn't downloaded them to the local device. Is there a way to force iCloud to pull down the sync files before running the sync registration or change the checkWhetherRemoteGlobalAppDirectoryExists to use an NSMetatdataQuery instead?

@MrRooni
Copy link
Contributor

MrRooni commented Jul 6, 2013

Austin,

I'm not sure on this one, let me see if I can get some help.

best,
Michael

@agrigg
Copy link
Author

agrigg commented Jul 6, 2013

Okay, thanks. I asked a question about NSMetadataQuery on Stackoverflow

http://stackoverflow.com/questions/17499331/how-do-i-determine-if-file-exists-in-icloud-folder

It sounds like this isn't really possible to know for sure if there are existing files on iCloud. The best I know to do at this point is to use the NSMetadataQuery and time out after 15-30 seconds and assume there are no files at that point. Not a great user experience, but that should only happen the first time they enable syncing on a device.

@drewmccormack
Copy link

I've just shipped my app Mental Case with TICD/iCloud sync. First sync is one of the weaknesses of the current setup, I'm afraid.

The way I have done it, I use a class called TIUbiquityMonitor in External Sources to wait for all data to download from iCloud. It is basically a glorified wrapper for NSMetadataQuery, but will count up how much data is not downloaded, and can even be used to activate downloads if they aren't already. This class may not be in the main branch of TICDS. If not, you can find it in my fork (drewmccormack).

The idea is just to try to download all the data before doing the first sync op. The problem can still arise, as you point out, that the device has not even received the metadata, and doesn't know about any files. There really isn't much you can do about this. What I do is simply state in a message to the user that no data was found. If they expected data to be there, they should just wait. Far from a great experience, but there is no way to force metadata to be retrieved. You could also just pause 30 seconds, as you say. That may catch most of the problems.

@agrigg
Copy link
Author

agrigg commented Jul 8, 2013

Okay, thanks for the info Drew, good to know the iCloud branch is seeing some real-world use. I'll check out the TIUbiquityMonitor.

One other question for you, how are you handling if someone logs out of iCloud or switches accounts? Are you keeping a separate database per iCloud account or using a fallback store? I wondered if I could even use the preconfigureDocumentSyncManager if someone logs out to keep generating sync changes and then sync those up when they log in again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants