perf(app): throttle upload progress callbacks to 256KB steps

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-28 14:10:29 +08:00
parent 203f62e7cb
commit 45dbde3719
3 changed files with 47 additions and 4 deletions
@@ -139,9 +139,15 @@ class DartHttpTransport implements Transport {
final file = File(filePath);
final length = await file.length();
var sent = 0;
var lastReported = 0;
// 256KB 步长节流(与原生 UploadPutExecutor 一致);末块必报 sent==length。
const progressStep = 256 * 1024;
final progressStream = file.openRead().map((List<int> chunk) {
sent += chunk.length;
onProgress?.call(sent, length);
if (sent - lastReported >= progressStep || sent == length) {
lastReported = sent;
onProgress?.call(sent, length);
}
return chunk;
});
try {