From b0850fb5e50d326acc9092826501fea554a6feb2 Mon Sep 17 00:00:00 2001
From: krau <71133316+krau@users.noreply.github.com>
Date: Sat, 22 Aug 2026 17:39:55 +0800
Subject: [PATCH] fix(batch): show total size in progress header again
The #228 progress redesign dropped the total size that the old
batch progress message displayed. Add a TotalSize data field
(actual known sizes, formatted via dlutil.FormatSize) to the
batch status header template in both locales.
---
common/i18n/locale/en.yaml | 2 +-
common/i18n/locale/zh-Hans.yaml | 2 +-
core/tasks/batchtfile/progress.go | 1 +
.../batchtfile/progress_regression_test.go | 24 +++++++++++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/common/i18n/locale/en.yaml b/common/i18n/locale/en.yaml
index 40f6e89..e944e8c 100644
--- a/common/i18n/locale/en.yaml
+++ b/common/i18n/locale/en.yaml
@@ -351,7 +351,7 @@ bot:
info_filename_prefix: "Filename: "
info_prompt_select_storage: "\nPlease select storage"
progress:
- batch_status_header: "📦 Processing\n\nFiles: {{.Total}}\nStatus: ✅ {{.Completed}} | 📥 {{.Downloaded}} | ⏳ {{.Waiting}}\nTotal speed: ⬇️ {{.DownloadSpeed}} | ⬆️ {{.UploadSpeed}}"
+ batch_status_header: "📦 Processing\n\nFiles: {{.Total}} | Total size: {{.TotalSize}}\nStatus: ✅ {{.Completed}} | 📥 {{.Downloaded}} | ⏳ {{.Waiting}}\nTotal speed: ⬇️ {{.DownloadSpeed}} | ⬆️ {{.UploadSpeed}}"
batch_item_downloading: "
⬇️ {{.Index}}/{{.Total}} Downloading\n" batch_item_downloading_unknown: "{{.Name}}\n{{.Bar}}{{.Progress}}%\nSpeed:{{.Speed}}\nSize:{{.Current}}/{{.Size}}
⬇️ {{.Index}}/{{.Total}} Downloading\n" batch_item_transferring: "{{.Name}}\nSpeed:{{.Speed}}\nSize:{{.Current}}/ unknown
↕️ {{.Index}}/{{.Total}} Transferring\n" diff --git a/common/i18n/locale/zh-Hans.yaml b/common/i18n/locale/zh-Hans.yaml index 1b2cc71..dc05fd9 100644 --- a/common/i18n/locale/zh-Hans.yaml +++ b/common/i18n/locale/zh-Hans.yaml @@ -352,7 +352,7 @@ bot: info_filename_prefix: "文件名: " info_prompt_select_storage: "\n请选择存储位置" progress: - batch_status_header: "📦 正在处理\n\n文件:{{.Name}}\n{{.Bar}}{{.Progress}}%\nSpeed:{{.Speed}}\nSize:{{.Current}}/{{.Size}}
{{.Total}}\n状态:✅ {{.Completed}} | 📥 {{.Downloaded}} | ⏳ {{.Waiting}}\n总速度:⬇️ {{.DownloadSpeed}} | ⬆️ {{.UploadSpeed}}"
+ batch_status_header: "📦 正在处理\n\n文件:{{.Total}} | 总大小:{{.TotalSize}}\n状态:✅ {{.Completed}} | 📥 {{.Downloaded}} | ⏳ {{.Waiting}}\n总速度:⬇️ {{.DownloadSpeed}} | ⬆️ {{.UploadSpeed}}"
batch_item_downloading: "⬇️ {{.Index}}/{{.Total}} 下载中\n" batch_item_downloading_unknown: "{{.Name}}\n{{.Bar}}{{.Progress}}%\n速度:{{.Speed}}\n大小:{{.Current}}/{{.Size}}
⬇️ {{.Index}}/{{.Total}} 下载中\n" batch_item_transferring: "{{.Name}}\n速度:{{.Speed}}\n大小:{{.Current}}/ 未知
↕️ {{.Index}}/{{.Total}} 传输中\n" diff --git a/core/tasks/batchtfile/progress.go b/core/tasks/batchtfile/progress.go index 52fac1d..a7c6ef7 100644 --- a/core/tasks/batchtfile/progress.go +++ b/core/tasks/batchtfile/progress.go @@ -152,6 +152,7 @@ func buildBatchProgressMessage(info TaskInfo, skipped []string, activeLimit int) uploadSpeedText := formatSpeed(uploadSpeed) header := localizedProgressMarkup(i18nk.BotMsgProgressBatchStatusHeader, map[string]any{ "Total": total, + "TotalSize": dlutil.FormatSize(info.ActualTotalSize()), "Completed": completed, "Downloaded": downloaded, "Waiting": waiting, diff --git a/core/tasks/batchtfile/progress_regression_test.go b/core/tasks/batchtfile/progress_regression_test.go index 750c58c..dc6dcb5 100644 --- a/core/tasks/batchtfile/progress_regression_test.go +++ b/core/tasks/batchtfile/progress_regression_test.go @@ -95,6 +95,30 @@ func TestBatchProgressShowsTransferSpeedAndSize(t *testing.T) { } } +func TestBatchProgressHeaderShowsTotalSize(t *testing.T) { + useProgressRegressionLocale(t) + task := newProgressRegressionTask(nil, + progressRegressionFile{"first", 1024}, + progressRegressionFile{"second", 1024}, + ) + message := buildBatchProgressMessage(task, nil, 2) + if message.Err != nil { + t.Fatalf("buildBatchProgressMessage() failed: %v", message.Err) + } + assertProgressRegressionContains(t, message.Text, + "文件:2 | 总大小:2.00 KB", + ) + + i18n.Init("en") + english := buildBatchProgressMessage(task, nil, 2) + if english.Err != nil { + t.Fatalf("English batch template failed: %v", english.Err) + } + assertProgressRegressionContains(t, english.Text, + "Files: 2 | Total size: 2.00 KB", + ) +} + func TestBatchProgressLimitsRowsWithoutHidingActiveUpload(t *testing.T) { useProgressRegressionLocale(t) task := newProgressRegressionTask(nil,{{.Name}}\n{{.Bar}}{{.Progress}}%\n速度:{{.Speed}}\n大小:{{.Current}}/{{.Size}}