mirror of
https://github.com/rclone/rclone.git
synced 2026-02-18 18:33:36 +00:00
accounting: update String method output format for clarity in transfer rate representation - fixes #9129
This commit is contained in:
committed by
GitHub
parent
e06f0b0595
commit
9601dbce87
@@ -575,8 +575,11 @@ func (acc *Account) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
var displaySpeedString string
|
||||
if acc.ci.DataRateUnit == "bits" {
|
||||
cur *= 8
|
||||
displaySpeedString = fs.SizeSuffix(cur * 8).BitRateUnit()
|
||||
} else {
|
||||
displaySpeedString = fs.SizeSuffix(cur).ByteRateUnit()
|
||||
}
|
||||
|
||||
percentageDone := 0
|
||||
@@ -584,12 +587,12 @@ func (acc *Account) String() string {
|
||||
percentageDone = int(100 * float64(a) / float64(b))
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%*s:%3d%% /%s, %s/s, %s",
|
||||
return fmt.Sprintf("%*s:%3d%% / %s, %s, %s",
|
||||
acc.ci.StatsFileNameLength,
|
||||
shortenName(acc.name, acc.ci.StatsFileNameLength),
|
||||
percentageDone,
|
||||
fs.SizeSuffix(b),
|
||||
fs.SizeSuffix(cur),
|
||||
fs.SizeSuffix(b).ByteUnit(),
|
||||
displaySpeedString,
|
||||
etas,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ func TestAccountString(t *testing.T) {
|
||||
|
||||
// FIXME not an exhaustive test!
|
||||
|
||||
assert.Equal(t, "test: 0% /3, 0/s, -", strings.TrimSpace(acc.String()))
|
||||
assert.Equal(t, "test: 0% / 3 B, 0 B/s, -", strings.TrimSpace(acc.String()))
|
||||
|
||||
var buf = make([]byte, 2)
|
||||
n, err := acc.Read(buf)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, n)
|
||||
|
||||
assert.Equal(t, "test: 66% /3, 0/s, -", strings.TrimSpace(acc.String()))
|
||||
assert.Equal(t, "test: 66% / 3 B, 0 B/s, -", strings.TrimSpace(acc.String()))
|
||||
|
||||
assert.NoError(t, acc.Close())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user