Fixed importing with a different key and entity access after MOC changes.
[FIXED] Importing stored content when not logged in with the same key. [FIXED] Holding entities is a bad idea when MOCs can change. Holding ObjectIDs instead now.
This commit is contained in:
@@ -7,12 +7,16 @@
|
||||
//
|
||||
|
||||
#import "MPAppDelegate_Shared.h"
|
||||
#import "MPAppDelegate_Store.h"
|
||||
|
||||
@interface MPAppDelegate_Shared ()
|
||||
|
||||
@property (strong) NSManagedObjectID *activeUserID;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPAppDelegate_Shared
|
||||
|
||||
@synthesize key;
|
||||
@synthesize activeUser;
|
||||
|
||||
+ (MPAppDelegate_Shared *)get {
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -41,4 +45,14 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
- (MPUserEntity *)activeUser {
|
||||
|
||||
return (MPUserEntity *)[self.managedObjectContextIfReady objectWithID:self.activeUserID];
|
||||
}
|
||||
|
||||
- (void)setActiveUser:(MPUserEntity *)activeUser {
|
||||
|
||||
self.activeUserID = activeUser.objectID;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -185,6 +185,7 @@
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
assert([key.keyID isEqualToData:self.user.keyID]);
|
||||
[self setContent:content usingKey:key];
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@
|
||||
- (void)setContent:(id)content usingKey:(MPKey *)key {
|
||||
|
||||
assert(self.type & MPElementTypeClassStored);
|
||||
assert([key.keyID isEqualToData:self.user.keyID]);
|
||||
assert(key);
|
||||
|
||||
NSData *encryptedContent = [[content description] encryptWithSymmetricKey:[key subKeyOfLength:PearlCryptKeySize].keyData padding:YES];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user