Skip to content

Commit 3861ac9

Browse files
author
Jorge Leandro Perez
authored
Merge pull request #609 from Simperium/develop
Simperium Mk 1.3
2 parents 37f0469 + 26a06da commit 3861ac9

3 files changed

Lines changed: 13 additions & 23 deletions

File tree

Simperium/SPEnvironment.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#endif
3131

3232
// TODO: Update this automatically via a script that looks at current git tag
33-
NSString* const SPLibraryVersion = @"1.2.0";
33+
NSString* const SPLibraryVersion = @"1.3.0";
3434

3535
/// SSL Pinning
3636
///

Simperium/SPJSONStorage.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
@interface SPJSONStorage : SPStorage<SPStorageProvider>
1414

1515
@property (nonatomic, strong) NSMutableDictionary *objects;
16-
@property (nonatomic, strong) NSMutableDictionary *ghosts;
17-
@property (nonatomic, strong) NSMutableArray *objectList;
1816
@property (nonatomic, strong) NSMutableDictionary *allObjects;
1917

2018
- (instancetype)initWithDelegate:(id<SPStorageObserver>)aDelegate;

Simperium/SPJSONStorage.m

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ - (instancetype)initWithDelegate:(id<SPStorageObserver>)aDelegate
3636
if (self) {
3737
_delegate = aDelegate;
3838
_objects = [NSMutableDictionary dictionaryWithCapacity:10];
39-
_ghosts = [NSMutableDictionary dictionaryWithCapacity:10];
4039
_allObjects = [NSMutableDictionary dictionaryWithCapacity:10];
41-
_objectList = [NSMutableArray arrayWithCapacity:10];
42-
40+
4341
NSString *queueLabel = @"com.simperium.JSONstorage";
4442
_storageQueue = dispatch_queue_create([queueLabel cStringUsingEncoding:NSUTF8StringEncoding], NULL);
4543
}
@@ -140,7 +138,7 @@ - (NSDictionary *)faultObjectsForKeys:(NSArray *)keys bucketName:(NSString *)buc
140138
// Batch fault a bunch of objects for efficiency
141139
// All objects are already in memory, for now at least...
142140
NSArray *objectsAsList = [self objectsForKeys:[NSSet setWithArray:keys] bucketName:bucketName];
143-
NSMutableDictionary *objectDict = [NSMutableDictionary dictionaryWithCapacity:_objectList.count];
141+
NSMutableDictionary *objectDict = [NSMutableDictionary dictionary];
144142
for (id<SPDiffable>object in objectsAsList) {
145143
[objectDict setObject:object forKey:object.simperiumKey];
146144
}
@@ -210,22 +208,16 @@ - (void)deleteObject:(id)dict
210208
}
211209

212210
- (void)deleteAllObjectsForBucketName:(NSString *)bucketName {
213-
// NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
214-
// NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:context];
215-
// [fetchRequest setEntity:entity];
216-
//
217-
// // No need to fault everything
218-
// [fetchRequest setIncludesPropertyValues:NO];
219-
//
220-
// NSError *error;
221-
// NSArray *items = [context executeFetchRequest:fetchRequest error:&error];
222-
//
223-
// for (NSManagedObject *managedObject in items) {
224-
// [context deleteObject:managedObject];
225-
// }
226-
// if (![context save:&error]) {
227-
// NSLog(@"Simperium error deleting %@ - error:%@",entityName,error);
228-
// }
211+
dispatch_sync(self.storageQueue, ^{
212+
// Nuke Bucket Entities from the `allObjects` collection
213+
NSDictionary<NSString *, SPObject *> *bucket = [self.objects objectForKey:bucketName];
214+
for (NSString *key in bucket.allKeys) {
215+
[self.allObjects removeObjectForKey:key];
216+
}
217+
218+
// And now nuke the entire bucket
219+
[self.objects removeObjectForKey:bucketName];
220+
});
229221
}
230222

231223
- (void)validateObjectsForBucketName:(NSString *)bucketName

0 commit comments

Comments
 (0)