From ce8cb9c851fa66c7c2902ceb57e369d3cecf1a28 Mon Sep 17 00:00:00 2001
From: lyg <1543117173@qq.com>
Date: 星期四, 01 八月 2024 01:48:56 +0800
Subject: [PATCH] 复制bt下载的文件,bt任务控制

---
 src/main.mjs |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main.mjs b/src/main.mjs
index 6f0a8eb..2fbe23a 100644
--- a/src/main.mjs
+++ b/src/main.mjs
@@ -4,7 +4,6 @@
 import path from "path";
 import { Worker, isMainThread, parentPort, workerData, threadId } from 'worker_threads';
 import { HttpsProxyAgent } from "https-proxy-agent";
-import { resolve } from "path";
 import { execFileSync } from "child_process";
 import wordsjs from 'wordlist-js';
 import usPlaceList from "./us-place-list.mjs";
@@ -43,7 +42,7 @@
  */
 async function getPdfPages(filepath) {
   const buf = fs.readFileSync(filepath);
-  const pdfDoc = await pdfLib.PDFDocument.load(buf);
+  const pdfDoc = await pdfLib.PDFDocument.load(buf, { ignoreEncryption: true });
   const pages = pdfDoc.getPages().length;
   return pages;
 }
@@ -344,7 +343,7 @@
           book.format = ext;
           book.file = filepath;
           book.url = url;
-          book.pages = await getPdfPages(filepath);
+          book.pages = await getPdfPages(filepath).catch(e => 0);
           resolve(true);
         });
         stream.on("error", (err) => {

--
Gitblit v1.9.1