Skip to content

Commit

Permalink
Merge pull request #609 from Simperium/develop
Browse files Browse the repository at this point in the history
Simperium Mk 1.3
  • Loading branch information
jleandroperez committed Jan 20, 2021
2 parents 37f0469 + 26a06da commit 3861ac9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Simperium/SPEnvironment.m
Expand Up @@ -30,7 +30,7 @@
#endif

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

/// SSL Pinning
///
Expand Down
2 changes: 0 additions & 2 deletions Simperium/SPJSONStorage.h
Expand Up @@ -13,8 +13,6 @@
@interface SPJSONStorage : SPStorage<SPStorageProvider>

@property (nonatomic, strong) NSMutableDictionary *objects;
@property (nonatomic, strong) NSMutableDictionary *ghosts;
@property (nonatomic, strong) NSMutableArray *objectList;
@property (nonatomic, strong) NSMutableDictionary *allObjects;

- (instancetype)initWithDelegate:(id<SPStorageObserver>)aDelegate;
Expand Down
32 changes: 12 additions & 20 deletions Simperium/SPJSONStorage.m
Expand Up @@ -36,10 +36,8 @@ - (instancetype)initWithDelegate:(id<SPStorageObserver>)aDelegate
if (self) {
_delegate = aDelegate;
_objects = [NSMutableDictionary dictionaryWithCapacity:10];
_ghosts = [NSMutableDictionary dictionaryWithCapacity:10];
_allObjects = [NSMutableDictionary dictionaryWithCapacity:10];
_objectList = [NSMutableArray arrayWithCapacity:10];


NSString *queueLabel = @"com.simperium.JSONstorage";
_storageQueue = dispatch_queue_create([queueLabel cStringUsingEncoding:NSUTF8StringEncoding], NULL);
}
Expand Down Expand Up @@ -140,7 +138,7 @@ - (NSDictionary *)faultObjectsForKeys:(NSArray *)keys bucketName:(NSString *)buc
// Batch fault a bunch of objects for efficiency
// All objects are already in memory, for now at least...
NSArray *objectsAsList = [self objectsForKeys:[NSSet setWithArray:keys] bucketName:bucketName];
NSMutableDictionary *objectDict = [NSMutableDictionary dictionaryWithCapacity:_objectList.count];
NSMutableDictionary *objectDict = [NSMutableDictionary dictionary];
for (id<SPDiffable>object in objectsAsList) {
[objectDict setObject:object forKey:object.simperiumKey];
}
Expand Down Expand Up @@ -210,22 +208,16 @@ - (void)deleteObject:(id)dict
}

- (void)deleteAllObjectsForBucketName:(NSString *)bucketName {
// NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:context];
// [fetchRequest setEntity:entity];
//
// // No need to fault everything
// [fetchRequest setIncludesPropertyValues:NO];
//
// NSError *error;
// NSArray *items = [context executeFetchRequest:fetchRequest error:&error];
//
// for (NSManagedObject *managedObject in items) {
// [context deleteObject:managedObject];
// }
// if (![context save:&error]) {
// NSLog(@"Simperium error deleting %@ - error:%@",entityName,error);
// }
dispatch_sync(self.storageQueue, ^{
// Nuke Bucket Entities from the `allObjects` collection
NSDictionary<NSString *, SPObject *> *bucket = [self.objects objectForKey:bucketName];
for (NSString *key in bucket.allKeys) {
[self.allObjects removeObjectForKey:key];
}

// And now nuke the entire bucket
[self.objects removeObjectForKey:bucketName];
});
}

- (void)validateObjectsForBucketName:(NSString *)bucketName
Expand Down

0 comments on commit 3861ac9

Please sign in to comment.