@@ -2314,30 +2314,26 @@ - (void)removeObjectForKey:(NSString *)key {
2314
2314
}
2315
2315
2316
2316
- (void )revert {
2317
- @synchronized (lock) {
2318
- if ([self isDirty ]) {
2319
- NSMutableArray *removedKeys = [NSMutableArray array ];
2320
- [removedKeys addObjectsFromArray: [self allKeys ]];
2321
- for (PFOperationSet *operationSet in operationSetQueue) {
2322
- for (NSString *key in operationSet.keyEnumerator ) {
2323
- [removedKeys addObject: key];
2324
- }
2325
- }
2326
-
2327
- PFOperationSet *changes = [self unsavedChanges ];
2328
- for (NSString *key in changes.keyEnumerator ) {
2329
- [changes removeObjectForKey: key];
2317
+ @synchronized (self.lock ) {
2318
+ NSMutableSet *persistentKeys = [NSMutableSet setWithArray: [self ._state.serverData allKeys ]];
2319
+
2320
+ PFOperationSet *unsavedChanges = [self unsavedChanges ];
2321
+ for (PFOperationSet *operationSet in operationSetQueue) {
2322
+ if (operationSet != unsavedChanges) {
2323
+ [persistentKeys addObjectsFromArray: [operationSet.keyEnumerator allObjects ]];
2330
2324
}
2331
-
2332
- [self rebuildEstimatedData ];
2333
- [_availableKeys minusSet: [NSSet setWithArray: removedKeys]];
2334
- [self checkpointAllMutableContainers ];
2335
2325
}
2326
+
2327
+ [unsavedChanges removeAllObjects ];
2328
+ [_availableKeys intersectSet: persistentKeys];
2329
+
2330
+ [self rebuildEstimatedData ];
2331
+ [self checkpointAllMutableContainers ];
2336
2332
}
2337
2333
}
2338
2334
2339
2335
- (void )revertObjectForKey : (NSString *)key {
2340
- @synchronized (lock) {
2336
+ @synchronized (self. lock ) {
2341
2337
if ([self isDirtyForKey: key]) {
2342
2338
[[self unsavedChanges ] removeObjectForKey: key];
2343
2339
[self rebuildEstimatedData ];
0 commit comments