(fileName string, current string, total string, percentage float64)
| 15 | } |
| 16 | |
| 17 | func DisplayDownloadFunction(fileName string, current string, total string, percentage float64) { |
| 18 | currentTime := time.Now() |
| 19 | |
| 20 | if currentTime.Sub(lastProgress) >= 5*time.Second { |
| 21 | |
| 22 | lastProgress = currentTime |
| 23 | |
| 24 | // calculate ETA based on percentage and elapsed time |
| 25 | var eta time.Duration |
| 26 | if percentage > 0 { |
| 27 | elapsed := currentTime.Sub(startTime) |
| 28 | eta = time.Duration(float64(elapsed)*(100/percentage) - float64(elapsed)) |
| 29 | } |
| 30 | |
| 31 | if total != "" { |
| 32 | xlog.Info("Downloading", "fileName", fileName, "current", current, "total", total, "percentage", percentage, "eta", eta) |
| 33 | } else { |
| 34 | xlog.Info("Downloading", "current", current) |
| 35 | } |
| 36 | } |
| 37 | } |
no outgoing calls
no test coverage detected