Show DCC send filesize
This commit is contained in:
@ -112,10 +112,10 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||
percentage := 100 * (float64(totalBytes) / float64(pack.Length))
|
||||
|
||||
progress <- DownloadProgress{
|
||||
Speed: humanReadableByteCount(averageSpeed, true),
|
||||
Speed: formatByteCount(averageSpeed, true),
|
||||
PercCompletion: percentage,
|
||||
BytesRemaining: humanReadableByteCount(bytesRemaining, false),
|
||||
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
||||
BytesRemaining: formatByteCount(bytesRemaining, false),
|
||||
BytesCompleted: formatByteCount(float64(totalBytes), false),
|
||||
SecondsElapsed: secondsSince(start),
|
||||
SecondsToGo: bytesRemaining / averageSpeed,
|
||||
File: pack.File,
|
||||
@ -127,7 +127,7 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||
if progress != nil {
|
||||
progress <- DownloadProgress{
|
||||
PercCompletion: 100,
|
||||
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
||||
BytesCompleted: formatByteCount(float64(totalBytes), false),
|
||||
SecondsElapsed: secondsSince(start),
|
||||
File: pack.File,
|
||||
}
|
||||
@ -136,6 +136,10 @@ func (pack *DCCSend) Download(w io.Writer, progress chan DownloadProgress) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pack *DCCSend) Size() string {
|
||||
return formatByteCount(float64(pack.Length), false)
|
||||
}
|
||||
|
||||
type DownloadProgress struct {
|
||||
File string `json:"file"`
|
||||
Error error `json:"error"`
|
||||
@ -172,7 +176,7 @@ const (
|
||||
gibibyte
|
||||
)
|
||||
|
||||
func humanReadableByteCount(b float64, speed bool) string {
|
||||
func formatByteCount(b float64, speed bool) string {
|
||||
unit := ""
|
||||
value := b
|
||||
|
||||
|
Reference in New Issue
Block a user