From af683e9faf0c12240de9a3e8d0d69b66e4bce8a2 Mon Sep 17 00:00:00 2001 From: Eridanus Sora Date: Sat, 19 Oct 2024 23:57:08 +0800 Subject: [PATCH] ignore erbose option in previous task. --- src/core/archive.ts | 3 --- src/index.ts | 7 +++++-- src/utils/log.ts | 8 ++------ src/utils/task.ts | 3 --- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/core/archive.ts b/src/core/archive.ts index 7b86ffd..44a4694 100644 --- a/src/core/archive.ts +++ b/src/core/archive.ts @@ -540,7 +540,6 @@ class ArchiveDownloader extends Downloader { this.cookies = previousTask.cookies; this.headers = previousTask.headers; this.key = previousTask.key; - this.verbose = previousTask.verbose; this.startedAt = new Date().valueOf(); this.totalChunksCount = previousTask.totalChunksCount - previousTask.finishedChunksCount; this.retries = previousTask.retries; @@ -550,7 +549,6 @@ class ArchiveDownloader extends Downloader { this.downloadTasks = previousTask.downloadTasks; this.finishedFilenames = previousTask.finishedFilenames; - logger.setDebugMode(this.verbose); if (this.headers && Object.keys(this.headers).length > 0) { // Apply global custom headers axios.defaults.headers.common = { @@ -628,7 +626,6 @@ class ArchiveDownloader extends Downloader { cookies: this.cookies, headers: this.headers, key: this.key, - verbose: this.verbose, startedAt: this.startedAt, finishedChunksCount: this.totalChunksCount - unfinishedTaskCount, finishedChunkLength: this.finishedChunkLength, diff --git a/src/index.ts b/src/index.ts index 0f1765c..01194cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,7 +53,7 @@ Erii.bind( async (ctx, options) => { const path = ctx.getArgument().toString(); if (options.verbose) { - logger.setDebugMode(true); + logger.enableDebugMode(); } if (!options.noProxy && !process.env.NO_PROXY) { if (process.platform === "win32") { @@ -105,6 +105,9 @@ Erii.bind( }, async (ctx, options) => { const path = ctx.getArgument().toString(); + if (options.verbose) { + logger.enableDebugMode(); + } const downloader = new ArchiveDownloader(undefined, { cliMode: true, }); @@ -125,7 +128,7 @@ Erii.bind( }, (ctx, options) => { if (options.verbose) { - logger.setDebugMode(true); + logger.enableDebugMode(); } const fileOptions = readConfigFile(); if (Object.keys(fileOptions).length > 0) { diff --git a/src/utils/log.ts b/src/utils/log.ts index c66e6e2..a179eeb 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -21,12 +21,8 @@ class ConsoleLogger { console.info(chalk.red(`[MINYAMI][ERROR] ${message}`)); } - setDebugMode(enabled: boolean): void { - this.isDebugMode = enabled; - } - - isDebugEnabled(): boolean { - return this.isDebugMode; + enableDebugMode() { + this.isDebugMode = true; } } diff --git a/src/utils/task.ts b/src/utils/task.ts index 58aa08f..b4082d6 100644 --- a/src/utils/task.ts +++ b/src/utils/task.ts @@ -22,9 +22,6 @@ export interface MinyamiTask { headers: Record; key: string; - /** 是否打印调试信息 */ - verbose: boolean; - /** 开始下载时间 */ startedAt: number; /** 已完成的块数量 */