Merge branch 'charlesmchen/flushDBChanges'

pull/1/head
Matthew Chen 6 years ago
commit 473f1e6ee4

@ -1237,6 +1237,8 @@ static NSTimeInterval launchStartedAt;
[self preheatDatabaseViews];
[self.primaryStorage touchDbAsync];
// Try to update account attributes every time we upgrade.
if ([self.tsAccountManager isRegistered]) {
AppVersion *appVersion = AppVersion.sharedInstance;

@ -337,6 +337,14 @@ static const int kYapDatabaseRangeMaxLength = 25000;
- (void)viewDidLoad
{
[self addNotificationListeners];
[self touchDbAsync];
}
- (void)touchDbAsync
{
// See comments in primaryStorage.touchDbAsync.
[self.primaryStorage touchDbAsync];
}
- (void)dealloc
@ -963,22 +971,8 @@ static const int kYapDatabaseRangeMaxLength = 25000;
[self.delegate conversationViewModelDidUpdate:ConversationUpdate.reloadUpdate];
}
- (void)touchDbAsync
{
OWSLogInfo(@"");
// There appears to be a bug in YapDatabase that sometimes delays modifications
// made in another process (e.g. the SAE) from showing up in other processes.
// There's a simple workaround: a trivial write to the database flushes changes
// made from other processes.
[self.editingDatabaseConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction setObject:[NSUUID UUID].UUIDString forKey:@"conversation_view_noop_mod" inCollection:@"temp"];
}];
}
- (void)applicationWillEnterForeground:(NSNotification *)notification
{
// See comments in touchDbAsync.
[self touchDbAsync];
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSStorage.h"
@ -42,6 +42,10 @@ extern NSString *const OWSUIDatabaseConnectionNotificationsKey;
+ (void)protectFiles;
#pragma mark - Misc.
- (void)touchDbAsync;
@end
NS_ASSUME_NONNULL_END

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSPrimaryStorage.h"
@ -431,6 +431,21 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;
}
#pragma mark - Misc.
- (void)touchDbAsync
{
OWSLogInfo(@"");
// There appears to be a bug in YapDatabase that sometimes delays modifications
// made in another process (e.g. the SAE) from showing up in other processes.
// There's a simple workaround: a trivial write to the database flushes changes
// made from other processes.
[self.dbReadWriteConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction setObject:[NSUUID UUID].UUIDString forKey:@"conversation_view_noop_mod" inCollection:@"temp"];
}];
}
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save