Fix broken detection after error loading a translator's code
The bug fixed in bde9a74f9d
was triggering an error getting code for a
deleted search translator, which due to this bug caused a double
complete() call that got detection all out of sync, which caused some
search translators to be skipped, which resulted in ISBN lookup
failures.
This commit is contained in:
parent
bde9a74f9d
commit
b8ad18e96d
1 changed files with 9 additions and 17 deletions
|
@ -1754,9 +1754,9 @@ Zotero.Translate.Base.prototype = {
|
||||||
/**
|
/**
|
||||||
* Loads the translator into its sandbox
|
* Loads the translator into its sandbox
|
||||||
* @param {Zotero.Translator} translator
|
* @param {Zotero.Translator} translator
|
||||||
* @return {Promise<Boolean>} Whether the translator could be successfully loaded
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
"_loadTranslator": Zotero.Promise.method(function (translator) {
|
_loadTranslator: async function (translator) {
|
||||||
var sandboxLocation = this._getSandboxLocation();
|
var sandboxLocation = this._getSandboxLocation();
|
||||||
if(!this._sandboxLocation || sandboxLocation !== this._sandboxLocation) {
|
if(!this._sandboxLocation || sandboxLocation !== this._sandboxLocation) {
|
||||||
this._sandboxLocation = sandboxLocation;
|
this._sandboxLocation = sandboxLocation;
|
||||||
|
@ -1798,25 +1798,17 @@ Zotero.Translate.Base.prototype = {
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
if (this.noWait) {
|
if (this.noWait) {
|
||||||
try {
|
|
||||||
let codePromise = translator.getCode();
|
let codePromise = translator.getCode();
|
||||||
if (!codePromise.isResolved()) {
|
if (!codePromise.isResolved()) {
|
||||||
throw new Error("Code promise is not resolved in noWait mode");
|
throw new Error("Code promise is not resolved in noWait mode");
|
||||||
}
|
}
|
||||||
parse(codePromise.value());
|
parse(codePromise.value());
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
this.complete(false, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
return translator.getCode()
|
let code = await translator.getCode();
|
||||||
.then(parse)
|
await parse(code);
|
||||||
.catch(function(e) {
|
|
||||||
this.complete(false, e);
|
|
||||||
}.bind(this));
|
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a sandbox for scraping/scraper detection
|
* Generates a sandbox for scraping/scraper detection
|
||||||
|
|
Loading…
Add table
Reference in a new issue