Fix crashing bug caused by nesting update statements.
This commit is contained in:
parent
be81fdae0a
commit
d289bbea94
|
@ -187,10 +187,10 @@ final class ArticlesTable: DatabaseTable {
|
||||||
|
|
||||||
func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
|
func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
|
||||||
|
|
||||||
self.queue.update { (database) in
|
self.queue.updateSync { (database) in
|
||||||
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, false, database)
|
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, false, database)
|
||||||
let statuses = Set(statusesDictionary.values)
|
let statuses = Set(statusesDictionary.values)
|
||||||
_ = self.statusesTable.mark(statuses, statusKey, flag)
|
_ = self.statusesTable.mark(statuses, statusKey, flag, database)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -312,8 +312,11 @@ final class ArticlesTable: DatabaseTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mark(_ articles: Set<Article>, _ statusKey: ArticleStatus.Key, _ flag: Bool) -> Set<ArticleStatus>? {
|
func mark(_ articles: Set<Article>, _ statusKey: ArticleStatus.Key, _ flag: Bool) -> Set<ArticleStatus>? {
|
||||||
|
var statuses: Set<ArticleStatus>?
|
||||||
return statusesTable.mark(articles.statuses(), statusKey, flag)
|
self.queue.updateSync { (database) in
|
||||||
|
statuses = self.statusesTable.mark(articles.statuses(), statusKey, flag, database)
|
||||||
|
}
|
||||||
|
return statuses
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Indexing
|
// MARK: Indexing
|
||||||
|
|
|
@ -50,7 +50,7 @@ final class StatusesTable: DatabaseTable {
|
||||||
|
|
||||||
// MARK: Marking
|
// MARK: Marking
|
||||||
|
|
||||||
func mark(_ statuses: Set<ArticleStatus>, _ statusKey: ArticleStatus.Key, _ flag: Bool) -> Set<ArticleStatus>? {
|
func mark(_ statuses: Set<ArticleStatus>, _ statusKey: ArticleStatus.Key, _ flag: Bool, _ database: FMDatabase) -> Set<ArticleStatus>? {
|
||||||
|
|
||||||
// Sets flag in both memory and in database.
|
// Sets flag in both memory and in database.
|
||||||
|
|
||||||
|
@ -70,9 +70,8 @@ final class StatusesTable: DatabaseTable {
|
||||||
}
|
}
|
||||||
let articleIDs = updatedStatuses.articleIDs()
|
let articleIDs = updatedStatuses.articleIDs()
|
||||||
|
|
||||||
queue.updateSync { (database) in
|
self.markArticleIDs(articleIDs, statusKey, flag, database)
|
||||||
self.markArticleIDs(articleIDs, statusKey, flag, database)
|
|
||||||
}
|
|
||||||
return updatedStatuses
|
return updatedStatuses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue