mirror of
https://github.com/rclone/rclone.git
synced 2025-01-11 00:40:03 +01:00
fs/accounting: show the total progress of the sync in the stats #379
This commit is contained in:
parent
cb7a461287
commit
80a3db34a8
@ -157,17 +157,46 @@ func (s *StatsInfo) String() string {
|
|||||||
speed = speed * 8
|
speed = speed * 8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
percent := func(a int64, b int64) int {
|
||||||
|
if b <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int(float64(a)*100/float64(b) + 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
totalChecks, totalTransfer, totalSize := int64(s.checkQueue)+s.checks, int64(s.transferQueue)+s.transfers, s.transferQueueSize+s.bytes
|
||||||
|
eta := time.Duration(0)
|
||||||
|
if speed > 0 {
|
||||||
|
eta = time.Second * time.Duration(float64(s.transferQueueSize)/float64(speed)+0.5)
|
||||||
|
}
|
||||||
|
etaString := "-"
|
||||||
|
if eta > 0 {
|
||||||
|
etaString = eta.String()
|
||||||
|
}
|
||||||
|
xfrchk := []string{}
|
||||||
|
if totalTransfer > 0 && s.transferQueue > 0 {
|
||||||
|
xfrchk = append(xfrchk, fmt.Sprintf("xfr#%d/%d", s.transfers, totalTransfer))
|
||||||
|
}
|
||||||
|
if totalChecks > 0 && s.checkQueue > 0 {
|
||||||
|
xfrchk = append(xfrchk, fmt.Sprintf("chk#%d/%d", s.checks, totalChecks))
|
||||||
|
}
|
||||||
|
xfrchkString := ""
|
||||||
|
if len(xfrchk) > 0 {
|
||||||
|
xfrchkString = fmt.Sprintf(" (%s)", strings.Join(xfrchk, ", "))
|
||||||
|
}
|
||||||
|
// FIXME make a one line display too
|
||||||
|
|
||||||
_, _ = fmt.Fprintf(buf, `
|
_, _ = fmt.Fprintf(buf, `
|
||||||
Transferred: %10s (%s)
|
Transferred: %10s / %s, %d%%, %s, ETA %s%s
|
||||||
Errors: %10d
|
Errors: %10d
|
||||||
Checks: %10d
|
Checks: %10d / %d, %d%%
|
||||||
Transferred: %10d
|
Transferred: %10d / %d, %d%%
|
||||||
Elapsed time: %10v
|
Elapsed time: %10v
|
||||||
`,
|
`,
|
||||||
fs.SizeSuffix(s.bytes).Unit("Bytes"), fs.SizeSuffix(speed).Unit(strings.Title(fs.Config.DataRateUnit)+"/s"),
|
fs.SizeSuffix(s.bytes), fs.SizeSuffix(totalSize).Unit("Bytes"), percent(s.bytes, totalSize), fs.SizeSuffix(speed).Unit(strings.Title(fs.Config.DataRateUnit)+"/s"), etaString, xfrchkString,
|
||||||
s.errors,
|
s.errors,
|
||||||
s.checks,
|
s.checks, totalChecks, percent(s.checks, totalChecks),
|
||||||
s.transfers,
|
s.transfers, totalTransfer, percent(s.transfers, totalTransfer),
|
||||||
dtRounded)
|
dtRounded)
|
||||||
|
|
||||||
// checking and transferring have their own locking so unlock
|
// checking and transferring have their own locking so unlock
|
||||||
|
Loading…
Reference in New Issue
Block a user