From 01611cbb0733a6031d54511cfb65ebb471afd8aa Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Wed, 22 Mar 2023 11:49:00 +0100 Subject: [PATCH] Temporarily disable folder import #2862 --- chrome/content/zotero/import/folderImport.js | 23 ++++++------------- .../content/zotero/import/importWizard.xhtml | 4 +++- test/tests/folderImportTest.js | 4 ++++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/import/folderImport.js b/chrome/content/zotero/import/folderImport.js index 6bc38ba093..26f7c6ac16 100644 --- a/chrome/content/zotero/import/folderImport.js +++ b/chrome/content/zotero/import/folderImport.js @@ -40,20 +40,9 @@ const findCollection = (libraryID, parentCollectionID, collectionName) => { return collections.find(c => c.name === collectionName); }; +// @TODO const findItemByHash = async (libraryID, hash) => { - let items = (await Zotero.Relations.getByPredicateAndObject('item', 'zotero:attachmentHash', hash)) - .filter(item => item.libraryID == libraryID && !item.deleted && item.isTopLevelItem()); - - if (!items.length) { - items = (await Zotero.Relations.getByPredicateAndObject('item', 'zotero:fileHash', hash)) - .filter(item => item.libraryID == libraryID && !item.deleted && item.isTopLevelItem()); - } - - if (!items.length) { - return null; - } - - return items[0]; + return null; }; class Zotero_Import_Folder { // eslint-disable-line camelcase,no-unused-vars @@ -92,6 +81,8 @@ class Zotero_Import_Folder { // eslint-disable-line camelcase,no-unused-vars } async translate({ collections = [], linkFiles = false } = {}) { + // https://github.com/zotero/zotero/pull/2862#discussion_r1141324302 + throw new Error('Folder import is not supported yet'); const libraryID = this.libraryID || Zotero.Libraries.userLibraryID; const files = await collectFilesRecursive(this.folder); @@ -201,7 +192,7 @@ class Zotero_Import_Folder { // eslint-disable-line camelcase,no-unused-vars } if (attachmentItem && !Zotero.RecognizePDF.canRecognize(attachmentItem)) { - attachmentItem.setRelations({ 'zotero:fileHash': hash }); + // @TODO: store hash of an item that cannot be recognized await attachmentItem.saveTx({ skipSelect: true }); attachmentItem = null; } @@ -225,13 +216,13 @@ class Zotero_Import_Folder { // eslint-disable-line camelcase,no-unused-vars if (status === Zotero.ProgressQueue.ROW_SUCCEEDED) { const recognizedItem = updatedItem.parentItem; if (recognizedItem && id in attachmentItemHashLookup) { - recognizedItem.setRelations({ 'zotero:attachmentHash': attachmentItemHashLookup[id] }); + // @TODO: Store hash of an attachment (attachmentItemHashLookup[id]) for this recognized item itemsToSavePostRecognize.push(recognizedItem); } } if (status === Zotero.ProgressQueue.ROW_FAILED) { if (updatedItem && id in attachmentItemHashLookup) { - updatedItem.setRelations({ 'zotero:fileHash': attachmentItemHashLookup[id] }); + // @TODO: Store hash of a file that failed to be recognized (attachmentItemHashLookup[id]) itemsToSavePostRecognize.push(updatedItem); } } diff --git a/chrome/content/zotero/import/importWizard.xhtml b/chrome/content/zotero/import/importWizard.xhtml index 348ab78fda..e25452794c 100644 --- a/chrome/content/zotero/import/importWizard.xhtml +++ b/chrome/content/zotero/import/importWizard.xhtml @@ -18,7 +18,9 @@ - + diff --git a/test/tests/folderImportTest.js b/test/tests/folderImportTest.js index 737f9d33b4..c81e269f4c 100644 --- a/test/tests/folderImportTest.js +++ b/test/tests/folderImportTest.js @@ -45,6 +45,8 @@ describe('Zotero_Import_Folder', function () { describe('#import', () => { it('should import PDFs from a folder and recreate structure without creating duplicates', async function () { + // @TODO: re-enable when folder import is ready + this.skip(); this.timeout(30000); if (Zotero.automatedTest) { this.skip(); @@ -104,6 +106,8 @@ describe('Zotero_Import_Folder', function () { }); it('should only import specified file types from a folder', async function () { + // @TODO: re-enable when folder import is ready + this.skip(); this.timeout(30000); if (Zotero.automatedTest) { this.skip();