mirror of
https://github.com/zotero/zotero.git
synced 2026-09-28 01:31:40 +00:00
Do not return recognizer promises early (#5148)
This commit is contained in:
parent
d6d01f66b9
commit
9579aa154a
1 changed files with 6 additions and 2 deletions
|
|
@ -58,8 +58,8 @@ Zotero.RecognizeDocument = new function () {
|
|||
async function _processQueue() {
|
||||
await Zotero.Schema.schemaUpdatePromise;
|
||||
|
||||
if (_queueProcessing) return;
|
||||
_queueProcessing = true;
|
||||
if (_queueProcessing) return _queueProcessing.promise;
|
||||
_queueProcessing = Zotero.Promise.defer();
|
||||
|
||||
while (1) {
|
||||
// While all current progress queue usages are related with
|
||||
|
|
@ -99,6 +99,7 @@ Zotero.RecognizeDocument = new function () {
|
|||
}
|
||||
}
|
||||
|
||||
_queueProcessing.resolve();
|
||||
_queueProcessing = false;
|
||||
_processingItemID = null;
|
||||
}
|
||||
|
|
@ -253,6 +254,7 @@ Zotero.RecognizeDocument = new function () {
|
|||
* @return {Promise} A promise that resolves to a newly created, recognized parent item
|
||||
*/
|
||||
async function _processItem(attachment) {
|
||||
Zotero.debug(`RecognizeDocument: Recognizing attachment ${attachment.getDisplayTitle()}`);
|
||||
// Make sure the attachment still doesn't have a parent
|
||||
if (attachment.parentItemID) {
|
||||
throw new Error('Already has parent');
|
||||
|
|
@ -270,8 +272,10 @@ Zotero.RecognizeDocument = new function () {
|
|||
|
||||
let parentItem = await Zotero.RecognizeDocument._recognize(attachment);
|
||||
if (!parentItem) {
|
||||
Zotero.debug(`RecognizeDocument: No matches for attachment ${attachment.getDisplayTitle()}`);
|
||||
throw new Zotero.Exception.Alert("recognizePDF.noMatches");
|
||||
}
|
||||
Zotero.debug(`RecognizeDocument: Recognized attachment ${attachment.getDisplayTitle()}`);
|
||||
|
||||
// Put new item in same collections as the old one
|
||||
let collections = attachment.getCollections();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue