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

PKSyncManager could potentially sync invalid data #32

Open
cwick opened this issue Dec 20, 2014 · 1 comment
Open

PKSyncManager could potentially sync invalid data #32

cwick opened this issue Dec 20, 2014 · 1 comment

Comments

@cwick
Copy link

cwick commented Dec 20, 2014

PKSyncManager currently uses NSManagedObjectContextWillSaveNotification to save changes to managed objects into the Dropbox datastore. According to this article, CoreData validations run after the WillSave notification is fired. Thus, you could have invalid data on a managed object, save the object, then PKSyncManager would pick up the changes and save them to the Dropbox datastore. Soon after, CoreData validations would fail for the object, but you've already saved the bad data to the Dropbox data store.

Is there a reason that PKSyncManager doesn't just use NSManagedObjectContextDidSaveNotification, which fires after coredata validations?

Note I haven't seen any problems like this in our app, it's just something I thought of that could theoretically happen, and I don't have time right now to actually try to write a failing test.

@cwick
Copy link
Author

cwick commented Dec 30, 2014

An update to this. I just wrote a unit test that shows that updateDatastoreWithManagedObject: gets called on PKSyncManager when an NSManagedObject with validation errors gets saved.

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

1 participant