Fix dictionary import total progress (#1921)

* Fix incorrect total count for final step of dictionary import

* Update tests to validate progress args
This commit is contained in:
toasted-nutbread 2021-08-31 21:42:18 -04:00 committed by GitHub
parent 02194fcb9f
commit 1599ec1f15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -126,7 +126,7 @@ class DictionaryImporter {
const {media} = await this._resolveAsyncRequirements(requirements, archive);
// Add dictionary descriptor
this._progressNextStep(termList.length + termMetaList.length + kanjiList.length + kanjiMetaList.length + tagList.length);
this._progressNextStep(termList.length + termMetaList.length + kanjiList.length + kanjiMetaList.length + tagList.length + media.length);
const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported});
dictionaryDatabase.bulkAdd('dictionaries', [summary], 0, 1);

View File

@ -43,7 +43,14 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
function createDictionaryImporter(onProgress) {
const dictionaryImporterMediaLoader = new DatabaseVMDictionaryImporterMediaLoader();
return new DictionaryImporter(dictionaryImporterMediaLoader, onProgress);
return new DictionaryImporter(dictionaryImporterMediaLoader, (...args) => {
const {stepIndex, stepCount, index, count} = args[0];
assert.ok(stepIndex < stepCount);
assert.ok(index <= count);
if (typeof onProgress === 'function') {
onProgress(...args);
}
});
}