style: fix prettier formatting
This commit is contained in:
parent
912546aaa7
commit
2169aa90e9
4 changed files with 9 additions and 15 deletions
|
|
@ -189,12 +189,12 @@ export async function handleConvert(
|
||||||
new RegExp(`${fileTypeOrig}(?!.*${fileTypeOrig})`),
|
new RegExp(`${fileTypeOrig}(?!.*${fileTypeOrig})`),
|
||||||
newFileExt,
|
newFileExt,
|
||||||
);
|
);
|
||||||
|
|
||||||
// For archive output converters, the actual file will have .tar extension
|
// For archive output converters, the actual file will have .tar extension
|
||||||
if (isArchiveOutput) {
|
if (isArchiveOutput) {
|
||||||
newFileName = `${newFileName}.tar`;
|
newFileName = `${newFileName}.tar`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetPath = `${userOutputDir}${newFileName.replace(/\.tar$/, "")}`;
|
const targetPath = `${userOutputDir}${newFileName.replace(/\.tar$/, "")}`;
|
||||||
toProcess.push(
|
toProcess.push(
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ export async function convert(
|
||||||
: mineruOutputDir;
|
: mineruOutputDir;
|
||||||
|
|
||||||
console.log(`[MinerU] Archiving directory: ${outputToArchive}`);
|
console.log(`[MinerU] Archiving directory: ${outputToArchive}`);
|
||||||
|
|
||||||
// 列出要封裝的內容
|
// 列出要封裝的內容
|
||||||
if (existsSync(outputToArchive)) {
|
if (existsSync(outputToArchive)) {
|
||||||
const contents = readdirSync(outputToArchive);
|
const contents = readdirSync(outputToArchive);
|
||||||
|
|
|
||||||
|
|
@ -266,21 +266,15 @@ export async function convert(
|
||||||
// - mono: 純翻譯版本(translated-<lang>.pdf)
|
// - mono: 純翻譯版本(translated-<lang>.pdf)
|
||||||
// - dual: 雙語對照版本(bilingual-<lang>.pdf)
|
// - dual: 雙語對照版本(bilingual-<lang>.pdf)
|
||||||
// ⚠️ 不包含原始 PDF,只包含翻譯結果
|
// ⚠️ 不包含原始 PDF,只包含翻譯結果
|
||||||
|
|
||||||
const translatedDest = join(archiveDir, `translated-${targetLang}.pdf`);
|
const translatedDest = join(archiveDir, `translated-${targetLang}.pdf`);
|
||||||
const bilingualDest = join(archiveDir, `bilingual-${targetLang}.pdf`);
|
const bilingualDest = join(archiveDir, `bilingual-${targetLang}.pdf`);
|
||||||
|
|
||||||
// 檢查各種可能的 mono 輸出檔案名稱
|
// 檢查各種可能的 mono 輸出檔案名稱
|
||||||
const possibleMonoOutputs = [
|
const possibleMonoOutputs = [monoPath, join(tempDir, `${inputFileName}-mono.pdf`)];
|
||||||
monoPath,
|
|
||||||
join(tempDir, `${inputFileName}-mono.pdf`),
|
|
||||||
];
|
|
||||||
|
|
||||||
// 檢查各種可能的 dual 輸出檔案名稱
|
// 檢查各種可能的 dual 輸出檔案名稱
|
||||||
const possibleDualOutputs = [
|
const possibleDualOutputs = [dualPath, join(tempDir, `${inputFileName}-dual.pdf`)];
|
||||||
dualPath,
|
|
||||||
join(tempDir, `${inputFileName}-dual.pdf`),
|
|
||||||
];
|
|
||||||
|
|
||||||
let foundMono = false;
|
let foundMono = false;
|
||||||
let foundDual = false;
|
let foundDual = false;
|
||||||
|
|
@ -309,7 +303,7 @@ export async function convert(
|
||||||
if (!foundMono && !foundDual) {
|
if (!foundMono && !foundDual) {
|
||||||
const allFiles = readdirSync(tempDir);
|
const allFiles = readdirSync(tempDir);
|
||||||
const pdfFiles = allFiles.filter((f) => f.endsWith(".pdf") && f !== basename(filePath));
|
const pdfFiles = allFiles.filter((f) => f.endsWith(".pdf") && f !== basename(filePath));
|
||||||
|
|
||||||
for (const pdfName of pdfFiles) {
|
for (const pdfName of pdfFiles) {
|
||||||
const pdfPath = join(tempDir, pdfName);
|
const pdfPath = join(tempDir, pdfName);
|
||||||
if (pdfName.includes("mono") || pdfName.includes("translated")) {
|
if (pdfName.includes("mono") || pdfName.includes("translated")) {
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ export const download = new Elysia()
|
||||||
const fileName = sanitize(decodeURIComponent(params.fileName));
|
const fileName = sanitize(decodeURIComponent(params.fileName));
|
||||||
|
|
||||||
const filePath = `${outputDir}${userId}/${jobId}/${fileName}`;
|
const filePath = `${outputDir}${userId}/${jobId}/${fileName}`;
|
||||||
|
|
||||||
// 檢查檔案是否存在
|
// 檢查檔案是否存在
|
||||||
if (!existsSync(filePath)) {
|
if (!existsSync(filePath)) {
|
||||||
console.error(`[Download] File not found: ${filePath}`);
|
console.error(`[Download] File not found: ${filePath}`);
|
||||||
set.status = 404;
|
set.status = 404;
|
||||||
return { error: "File not found", path: filePath };
|
return { error: "File not found", path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bun.file(filePath);
|
return Bun.file(filePath);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue