Merge pull request #77 from lae/fix/async-bulk-import-failure
Import terms/kanji with transactional adds instead of bulkAdd on async
This commit is contained in:
commit
a0d8e9d81b
@ -187,9 +187,9 @@ class Database {
|
||||
callback(total, current);
|
||||
}
|
||||
|
||||
const rows = [];
|
||||
await this.db.transaction('rw', this.db.terms, async function() {
|
||||
for (const [expression, reading, tags, rules, score, ...glossary] of entries) {
|
||||
rows.push({
|
||||
this.db.terms.add({
|
||||
expression,
|
||||
reading,
|
||||
tags,
|
||||
@ -199,8 +199,7 @@ class Database {
|
||||
dictionary: title
|
||||
});
|
||||
}
|
||||
|
||||
await this.db.terms.bulkAdd(rows);
|
||||
});
|
||||
};
|
||||
|
||||
const kanjiLoaded = async (title, entries, total, current) => {
|
||||
@ -208,9 +207,9 @@ class Database {
|
||||
callback(total, current);
|
||||
}
|
||||
|
||||
const rows = [];
|
||||
await this.db.transaction('rw', this.db.kanji, async function() {
|
||||
for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) {
|
||||
rows.push({
|
||||
this.db.kanji.add({
|
||||
character,
|
||||
onyomi,
|
||||
kunyomi,
|
||||
@ -219,8 +218,7 @@ class Database {
|
||||
dictionary: title
|
||||
});
|
||||
}
|
||||
|
||||
await this.db.kanji.bulkAdd(rows);
|
||||
});
|
||||
};
|
||||
|
||||
await Database.importDictionaryZip(archive, indexLoaded, termsLoaded, kanjiLoaded);
|
||||
|
Loading…
Reference in New Issue
Block a user