From 095ad565f517a03e147a734e8e611ba8be22b1d8 Mon Sep 17 00:00:00 2001 From: theluyuan <1162963624@qq.com> Date: Mon, 31 Jul 2023 22:41:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=8F=91=E7=A7=8D=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E6=89=8D=E8=BF=9B=E8=A1=8C=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/Download/index.js | 46 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/util/Download/index.js b/util/Download/index.js index 3792c11..a2a7fe9 100644 --- a/util/Download/index.js +++ b/util/Download/index.js @@ -87,6 +87,32 @@ async function reName(dinfo) { } +function dowv(dinfo){ + return new Promise((res)=>{ + dow(dinfo, async (msg, s) => { + console.log(String(msg)) + if (s) { + let exist = fileIsExist(dinfo.save + "/" + dinfo.title + ".mp4") + if (exist) { + // 设置状态 + let s = await reName(dinfo) + await setDownState(dinfo.id, s.state) + state = false + if (s.info) { + await sendSeed(s.info) + } + res(s) + } else { + // 重新下载 + console.log("下载失败重新下载") + state = false + } + } + }) + }) + +} + // 当前下载状态 let state = false async function CheckDown() { @@ -98,25 +124,7 @@ async function CheckDown() { state = true let dinfo = list[0] mkdirRecursions(dinfo.save) - dow(dinfo, async (msg, s) => { - console.log(String(msg)) - if (s) { - let exist = fileIsExist(dinfo.save + "/" + dinfo.title + ".mp4") - if (exist) { - // 设置状态 - let s = await reName(dinfo) - await setDownState(dinfo.id, s.state) - state = false - if (s.info) { - sendSeed(s.info) - } - } else { - // 重新下载 - console.log("下载失败重新下载") - state = false - } - } - }) + await dowv(dinfo) } }