More robust against exceptions and a few other fixes.
This commit is contained in:
parent
bb97e8f3e8
commit
85dab50996
2
External/Pearl
vendored
2
External/Pearl
vendored
@ -1 +1 @@
|
||||
Subproject commit 717bc5e5e7be3aedb997581260b67579eb651f8e
|
||||
Subproject commit 3c7b13b3649c92f7d30e4b8bd0570c8c6b1798c6
|
@ -32,6 +32,13 @@ fi
|
||||
|
||||
### DEPENDENCIES
|
||||
|
||||
digest() {
|
||||
if hash xxd 2>/dev/null; then
|
||||
openssl sha1 -binary < "$1" | xxd -p
|
||||
else
|
||||
openssl sha1 < "$1" | sed 's/.* //'
|
||||
fi
|
||||
}
|
||||
fetch() {
|
||||
if hash wget 2>/dev/null; then
|
||||
wget -O "${1##*/}" "$1"
|
||||
@ -54,7 +61,7 @@ unpack() {
|
||||
fi
|
||||
|
||||
printf 'Verifying package: %s, against digest: %s...' "$1" "$2"
|
||||
[[ $(openssl sha < "$1") = $2 ]] || {
|
||||
[[ $(digest "$1") = $2 ]] || {
|
||||
printf ' mismatch!\n'
|
||||
echo 2>&1 "Downloaded package doesn't match digest."
|
||||
exit 1
|
||||
|
@ -56,7 +56,11 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
return NO;
|
||||
|
||||
[mainManagedObjectContext performBlock:^{
|
||||
@try {
|
||||
mocBlock( mainManagedObjectContext );
|
||||
} @catch (NSException *exception) {
|
||||
err( @"While performing managed block:\n%@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
|
||||
return YES;
|
||||
@ -69,7 +73,12 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
return NO;
|
||||
|
||||
[mainManagedObjectContext performBlockAndWait:^{
|
||||
@try {
|
||||
mocBlock( mainManagedObjectContext );
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
err( @"While performing managed block:\n%@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
|
||||
return YES;
|
||||
@ -84,7 +93,12 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
|
||||
moc.parentContext = privateManagedObjectContextIfReady;
|
||||
[moc performBlock:^{
|
||||
@try {
|
||||
mocBlock( moc );
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
err( @"While performing managed block:\n%@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
|
||||
return YES;
|
||||
@ -99,7 +113,12 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
|
||||
moc.parentContext = privateManagedObjectContextIfReady;
|
||||
[moc performBlockAndWait:^{
|
||||
@try {
|
||||
mocBlock( moc );
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
err( @"While performing managed block:\n%@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
|
||||
return YES;
|
||||
@ -195,7 +214,12 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
^(NSNotification *note) {
|
||||
// When privateManagedObjectContext is saved, import the changes into mainManagedObjectContext.
|
||||
[self.mainManagedObjectContext performBlock:^{
|
||||
@try {
|
||||
[self.mainManagedObjectContext mergeChangesFromContextDidSaveNotification:note];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
err( @"While merging changes:\n%@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
}];
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
success = NO;
|
||||
err( @"While saving: %@", exception );
|
||||
err( @"While saving: %@", [exception fullDescription] );
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -128,10 +128,15 @@
|
||||
|
||||
- (NSString *)debugDescription {
|
||||
|
||||
@try {
|
||||
return strf( @"{%@: name=%@, user=%@, type=%lu, uses=%ld, lastUsed=%@, version=%ld, loginName=%@, requiresExplicitMigration=%d}",
|
||||
NSStringFromClass( [self class] ), self.name, self.user.name, (long)self.type, (long)self.uses, self.lastUsed,
|
||||
(long)self.version,
|
||||
self.loginName, self.requiresExplicitMigration );
|
||||
} @catch (NSException *exception) {
|
||||
return strf( @"{%@: inaccessible: %@}",
|
||||
NSStringFromClass( [self class] ), [exception fullDescription] );
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tryMigrateExplicitly:(BOOL)explicit {
|
||||
|
@ -257,8 +257,11 @@
|
||||
return;
|
||||
|
||||
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
||||
[context deleteObject:[self siteInContext:context]];
|
||||
MPSiteEntity *site_ = [self siteInContext:context];
|
||||
if (site_) {
|
||||
[context deleteObject:site_];
|
||||
[context saveToStore];
|
||||
}
|
||||
}];
|
||||
} cancelTitle:@"Cancel" destructiveTitle:@"Delete Site" otherTitles:nil];
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
||||
forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
|
||||
|
||||
if (controller == _fetchedResultsController) {
|
||||
@try {
|
||||
[self.passwordCollectionView performBatchUpdates:^{
|
||||
[self fetchedItemsDidUpdate];
|
||||
switch (type) {
|
||||
@ -188,6 +189,11 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
||||
}
|
||||
} completion:nil];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
wrn( @"While updating password cells: %@", [exception fullDescription] );
|
||||
[self.passwordCollectionView reloadData];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
|
||||
@ -375,6 +381,7 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
||||
if (![self.fetchedResultsController performFetch:&error])
|
||||
err( @"Couldn't fetch sites: %@", [error fullDescription] );
|
||||
|
||||
@try {
|
||||
[self.passwordCollectionView performBatchUpdates:^{
|
||||
[self fetchedItemsDidUpdate];
|
||||
|
||||
@ -397,6 +404,11 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
|
||||
[self.passwordCollectionView setContentOffset:CGPointMake( 0, -self.passwordCollectionView.contentInset.top )
|
||||
animated:YES];
|
||||
}];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
wrn( @"While updating password cells: %@", [exception fullDescription] );
|
||||
[self.passwordCollectionView reloadData];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user