()
| 388 | } |
| 389 | |
| 390 | func (w *WriteCounter) SaveProcess() { |
| 391 | percentValue := 0.0 |
| 392 | if w.Total > 0 { |
| 393 | percent := float64(w.Written) / float64(w.Total) * 100 |
| 394 | percentValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", percent), 64) |
| 395 | } |
| 396 | process := Process{ |
| 397 | Total: w.Total, |
| 398 | Written: w.Written, |
| 399 | Percent: percentValue, |
| 400 | Name: w.Name, |
| 401 | } |
| 402 | by, _ := json.Marshal(process) |
| 403 | if percentValue < 100 { |
| 404 | global.CACHE.Set(w.Key, string(by)) |
| 405 | } else { |
| 406 | global.CACHE.SetWithTTL(w.Key, string(by), time.Second*time.Duration(10)) |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | func buildDownloadProxyURL(proxy DownloadProxyConfig) (*url.URL, error) { |
| 411 | proxyType := strings.TrimSpace(proxy.Type) |
no test coverage detected