feat(traffic): update progress when caching file (#646)

* feat(traffic): update progress when caching file

* 调整参数位置和命名

---------

Co-authored-by: j2rong4cn <j2rong@qq.com>
This commit is contained in:
Seven
2025-07-08 21:41:45 +08:00
committed by GitHub
parent 9e610af114
commit 3838ef0663
16 changed files with 96 additions and 45 deletions

View File

@ -55,6 +55,19 @@ type FileStreamer interface {
type UpdateProgress func(percentage float64)
func UpdateProgressWithRange(inner UpdateProgress, start, end float64) UpdateProgress {
return func(p float64) {
if p < 0 {
p = 0
}
if p > 100 {
p = 100
}
scaled := start + (end-start)*(p/100.0)
inner(scaled)
}
}
type URL interface {
URL() string
}