From a8de167547e635f3e0f87a4bc0b3cf211a0e23b7 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Tue, 23 Apr 2024 15:48:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20back:=20when=20indexing=20docume?= =?UTF-8?q?nts,=20call=20unoconv=20directly=20to=20ignore=20stderr=20outpu?= =?UTF-8?q?t.=20And=20do=20not=20try=20indexing=20multiple=20ways.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tdrive/backend/node/src/services/documents/utils.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tdrive/backend/node/src/services/documents/utils.ts b/tdrive/backend/node/src/services/documents/utils.ts index a59c4adb..fd0de488 100644 --- a/tdrive/backend/node/src/services/documents/utils.ts +++ b/tdrive/backend/node/src/services/documents/utils.ts @@ -1,8 +1,8 @@ +import { spawnCheckingExitCode } from "../../utils/exec"; import archiver from "archiver"; import { merge } from "lodash"; import PdfParse from "pdf-parse"; import { Readable } from "stream"; -import unoconv from "unoconv-promise"; import Repository from "../../core/platform/services/database/services/orm/repository/repository"; import { cleanFiles, @@ -387,11 +387,7 @@ export const officeFileToString = async (file: Readable, extension: string): Pro const outputPath = getTmpFile(".pdf"); try { - await unoconv.run({ - file: officeFilePath, - output: outputPath, - }); - + await spawnCheckingExitCode("unoconv", [`-o${outputPath}`, officeFilePath]); cleanFiles([officeFilePath]); return await pdfFileToString(outputPath); @@ -633,11 +629,11 @@ export const getKeywordsOfFile = async ( logger.info(`Processing text file: ${filename}`); content_strings = await readableToString(file); } - if (isFileType(mime, filename, pdfExtensions)) { + if ((content_strings ?? "").trim().length == 0 && isFileType(mime, filename, pdfExtensions)) { logger.info(`Processing PDF file: ${filename}`); content_strings = await pdfFileToString(file); } - if (isFileType(mime, filename, officeExtensions)) { + if ((content_strings ?? "").trim().length == 0 && isFileType(mime, filename, officeExtensions)) { logger.info(`Processing office file: ${filename}`); content_strings = await officeFileToString(file, extension); }