mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 04:06:18 +08:00
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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user