refactor: 改进后端工具类 - 增强日志功能和工具函数

This commit is contained in:
Tianpao
2026-02-01 12:22:13 +08:00
parent 0a47d14627
commit 475d028ed9
2 changed files with 88 additions and 6 deletions

View File

@@ -193,7 +193,7 @@ export async function fastdownload(data: [string, string]|string[][]) {
export async function Wfastdownload(data: string[][], ws: MessageWS) {
logger.info(`Starting web download of ${data.length} files`);
let index = 0;
return await pMap(
data,
async (item: string[], idx: number) => {
@@ -214,7 +214,7 @@ export async function Wfastdownload(data: string[][], ws: MessageWS) {
}
// 更新下载进度
ws.download(data.length, idx + 1, filePath);
ws.download(data.length, ++index, filePath);
},
{ retries: 3, onFailedAttempt: (error) => {
logger.warn(`Download attempt failed for ${url}, retrying (${error.attemptNumber}/3)`);