diff --git a/cli/command_repository_sync.go b/cli/command_repository_sync.go index cb5bcbf82..0882fdb34 100644 --- a/cli/command_repository_sync.go +++ b/cli/command_repository_sync.go @@ -246,7 +246,7 @@ func (c *commandRepositorySyncTo) runSyncBlobs(ctx context.Context, src blob.Rea if est, ok := tt.Estimate(float64(bytesCopied), float64(totalBytes)); ok { eta = fmt.Sprintf("%v (%v)", est.Remaining, formatTimestamp(est.EstimatedEndTime)) - speed = units.BitsPerSecondsString(est.SpeedPerSecond * 8) //nolint:gomnd + speed = units.BytesPerSecondsString(est.SpeedPerSecond) } c.outputSyncProgress( diff --git a/cli/command_restore.go b/cli/command_restore.go index 3b3355232..ceb1e7740 100644 --- a/cli/command_restore.go +++ b/cli/command_restore.go @@ -24,7 +24,7 @@ const ( restoreCommandHelp = `Restore a directory or a file. -Restore can operate in two modes: +Restore can operate in two modes: * from a snapshot: restoring (possibly shallowly) a specified file or directory from a snapshot into a target path. By default, the target @@ -33,7 +33,7 @@ * by expanding a shallow placeholder in situ where the placeholder was created by a previous restore. -In the from-snapshot mode: +In the from-snapshot mode: The source to be restored is specified in the form of a directory or file ID and optionally a sub-directory path. @@ -87,7 +87,6 @@ 2. one or more placeholder files of the form path.kopia-entry ` - bitsPerByte = 8 unlimitedDepth = math.MaxInt32 ) @@ -362,9 +361,8 @@ func (c *commandRestore) run(ctx context.Context, rep repo.Repository) error { var maybeRemaining, maybeSkipped, maybeErrors string if est, ok := eta.Estimate(float64(stats.RestoredTotalFileSize), float64(stats.EnqueuedTotalFileSize)); ok { - bitsPerSecond := est.SpeedPerSecond * float64(bitsPerByte) maybeRemaining = fmt.Sprintf(" %v (%.1f%%) remaining %v", - units.BitsPerSecondsString(bitsPerSecond), + units.BytesPerSecondsString(est.SpeedPerSecond), est.PercentComplete, est.Remaining) } diff --git a/internal/units/units.go b/internal/units/units.go index 5564efb53..f082e45aa 100644 --- a/internal/units/units.go +++ b/internal/units/units.go @@ -39,10 +39,10 @@ func BytesStringBase2(b int64) string { return toDecimalUnitString(float64(b), 1024.0, base2UnitPrefixes, "B") } -// BitsPerSecondsString formats the given value bits per second with the appropriate suffix (Kbit/s, Mbit/s, Gbit/s, ...) -func BitsPerSecondsString(bps float64) string { +// BytesPerSecondsString formats the given value bytes per second with the appropriate base-10 suffix (KB/s, MB/s, GB/s, ...) +func BytesPerSecondsString(bps float64) string { // nolint:gomnd - return toDecimalUnitString(bps, 1000, base10UnitPrefixes, "bit/s") + return toDecimalUnitString(bps, 1000, base10UnitPrefixes, "B/s") } // Count returns the given number with the appropriate base-10 suffix (K, M, G, ...)