From a7b8370791bacfabde8f3e17f00d3c8edc684106 Mon Sep 17 00:00:00 2001 From: CosmosJunk Date: Fri, 18 Oct 2024 06:16:51 +0800 Subject: [PATCH 1/3] Fix typo in sleep() --- src/utils/system.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/system.ts b/src/utils/system.ts index b89a19c..793d93e 100644 --- a/src/utils/system.ts +++ b/src/utils/system.ts @@ -6,7 +6,7 @@ import logger from "./log"; export const exec = util.promisify(require("child_process").exec); -export const sleep = (deley) => new Promise((resolve) => setTimeout(resolve, deley)); +export const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)); export const deleteDirectory = (directoryPath: string, fileList: string[] = []) => { for (const filename of fileList) { From 0b3548d2a2c723d553c5b10f353cf0752a156625 Mon Sep 17 00:00:00 2001 From: CosmosJunk Date: Fri, 18 Oct 2024 06:32:44 +0800 Subject: [PATCH 2/3] fix verbose mode in resume mode --- src/core/archive.ts | 2 ++ src/utils/log.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/core/archive.ts b/src/core/archive.ts index 219cbf9..7b86ffd 100644 --- a/src/core/archive.ts +++ b/src/core/archive.ts @@ -549,6 +549,8 @@ class ArchiveDownloader extends Downloader { this.allDownloadTasks = previousTask.allDownloadTasks; 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 = { diff --git a/src/utils/log.ts b/src/utils/log.ts index a179eeb..8cf084c 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -24,6 +24,14 @@ class ConsoleLogger { enableDebugMode() { this.isDebugMode = true; } + + setDebugMode(enabled: boolean): void { + this.isDebugMode = enabled; + } + + isDebugEnabled(): boolean { + return this.isDebugMode; + } } export default new ConsoleLogger(); From 4f90d35ac2cd5aa5508ec60adb27f10e16ebda48 Mon Sep 17 00:00:00 2001 From: CosmosJunk Date: Fri, 18 Oct 2024 19:41:30 +0800 Subject: [PATCH 3/3] replace enableDebugMode() with setDebugMode() --- src/index.ts | 4 ++-- src/utils/log.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 98c126e..0f1765c 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.enableDebugMode(); + logger.setDebugMode(true); } if (!options.noProxy && !process.env.NO_PROXY) { if (process.platform === "win32") { @@ -125,7 +125,7 @@ Erii.bind( }, (ctx, options) => { if (options.verbose) { - logger.enableDebugMode(); + logger.setDebugMode(true); } const fileOptions = readConfigFile(); if (Object.keys(fileOptions).length > 0) { diff --git a/src/utils/log.ts b/src/utils/log.ts index 8cf084c..c66e6e2 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -21,10 +21,6 @@ class ConsoleLogger { console.info(chalk.red(`[MINYAMI][ERROR] ${message}`)); } - enableDebugMode() { - this.isDebugMode = true; - } - setDebugMode(enabled: boolean): void { this.isDebugMode = enabled; }