🩹 back: when indexing documents, call unoconv directly to ignore stderr output. And do not try indexing multiple ways.
This commit is contained in:
committed by
ericlinagora
parent
79fc8f2ad8
commit
a8de167547
@@ -1,8 +1,8 @@
|
|||||||
|
import { spawnCheckingExitCode } from "../../utils/exec";
|
||||||
import archiver from "archiver";
|
import archiver from "archiver";
|
||||||
import { merge } from "lodash";
|
import { merge } from "lodash";
|
||||||
import PdfParse from "pdf-parse";
|
import PdfParse from "pdf-parse";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import unoconv from "unoconv-promise";
|
|
||||||
import Repository from "../../core/platform/services/database/services/orm/repository/repository";
|
import Repository from "../../core/platform/services/database/services/orm/repository/repository";
|
||||||
import {
|
import {
|
||||||
cleanFiles,
|
cleanFiles,
|
||||||
@@ -387,11 +387,7 @@ export const officeFileToString = async (file: Readable, extension: string): Pro
|
|||||||
const outputPath = getTmpFile(".pdf");
|
const outputPath = getTmpFile(".pdf");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await unoconv.run({
|
await spawnCheckingExitCode("unoconv", [`-o${outputPath}`, officeFilePath]);
|
||||||
file: officeFilePath,
|
|
||||||
output: outputPath,
|
|
||||||
});
|
|
||||||
|
|
||||||
cleanFiles([officeFilePath]);
|
cleanFiles([officeFilePath]);
|
||||||
|
|
||||||
return await pdfFileToString(outputPath);
|
return await pdfFileToString(outputPath);
|
||||||
@@ -633,11 +629,11 @@ export const getKeywordsOfFile = async (
|
|||||||
logger.info(`Processing text file: ${filename}`);
|
logger.info(`Processing text file: ${filename}`);
|
||||||
content_strings = await readableToString(file);
|
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}`);
|
logger.info(`Processing PDF file: ${filename}`);
|
||||||
content_strings = await pdfFileToString(file);
|
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}`);
|
logger.info(`Processing office file: ${filename}`);
|
||||||
content_strings = await officeFileToString(file, extension);
|
content_strings = await officeFileToString(file, extension);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user