From 6e2d22a7138b4984a296c8b08af2dc4173c9be7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=99=BB=E5=B1=B1?= Date: Wed, 4 Mar 2026 17:03:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20Update=20the=20upload=20progress?= =?UTF-8?q?.=20rustfs/rustfs#2067?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/task-manager.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/task-manager.ts b/lib/task-manager.ts index 761edc0..3ca29a3 100644 --- a/lib/task-manager.ts +++ b/lib/task-manager.ts @@ -173,10 +173,22 @@ export class TaskManager, TStatus extends str } } + private watchProgress(task: TTask, lifecycle: TaskLifecycleStatus) { + let lastProgress = task.progress + const timer = setInterval(() => { + if (task.status !== lifecycle.running) return + if (task.progress === lastProgress) return + lastProgress = task.progress + this.notify() + }, 120) + return () => clearInterval(timer) + } + private async runTask(task: TTask) { const lifecycle = this.getLifecycle(task) as TaskLifecycleStatus task.status = lifecycle.running this.notify() + const stopWatchingProgress = this.watchProgress(task, lifecycle) try { const handler = this.getHandler(task) @@ -198,6 +210,7 @@ export class TaskManager, TStatus extends str this.notify() this.checkAllCompleted() } finally { + stopWatchingProgress() this.activeCount-- if (this.isStarted) setTimeout(() => this.processQueue(), 50) }