From a5c1341b0cfba55dc263deb74394c6135ac2d2ea Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 4 Dec 2019 22:11:20 -0800 Subject: [PATCH] =?UTF-8?q?Resume=20databases=20for=20all=20accounts=20bef?= =?UTF-8?q?ore=20resuming=20anything=20else,=20so=20that=20notifications?= =?UTF-8?q?=20don=E2=80=99t=20trigger=20database=20calls.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Account/Account.swift | 9 ++++++++- Frameworks/Account/AccountManager.swift | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index ae58d608a..93ca065f6 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -417,9 +417,15 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, opmlFile.suspend() } - public func resume() { + /// Re-open the SQLite database and allow database calls. + /// Call this *before* calling resume. + public func resumeDatabaseAndDelegate() { database.resume() delegate.resume() + } + + /// Reload OPML, etc. + public func resume() { metadataFile.resume() webFeedMetadataFile.resume() opmlFile.resume() @@ -481,6 +487,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, for feed in flattenedWebFeeds() { feed.metadata = webFeedMetadata(feedURL: feed.url, webFeedID: feed.webFeedID) } + precondition(!database.isSuspended) fetchAllUnreadCounts() NotificationCenter.default.post(name: .WebFeedMetadataDidChange, object: self, userInfo: nil) } diff --git a/Frameworks/Account/AccountManager.swift b/Frameworks/Account/AccountManager.swift index db8499ca3..0841ba8c7 100644 --- a/Frameworks/Account/AccountManager.swift +++ b/Frameworks/Account/AccountManager.swift @@ -175,6 +175,7 @@ public final class AccountManager: UnreadCountProvider { public func resumeAll() { isSuspended = false + accounts.forEach { $0.resumeDatabaseAndDelegate() } accounts.forEach { $0.resume() } }