diff --git a/lib/db/lowlevel.go b/lib/db/lowlevel.go index 557dc49b4..4b11165e7 100644 --- a/lib/db/lowlevel.go +++ b/lib/db/lowlevel.go @@ -827,7 +827,7 @@ func (db *Lowlevel) loadMetadataTracker(folder string) *metadataTracker { } if age := time.Since(meta.Created()); age > db.recheckInterval { - l.Infof("Stored folder metadata for %q is %v old; recalculating", folder, age) + l.Infof("Stored folder metadata for %q is %v old; recalculating", folder, util.NiceDurationString(age)) return db.getMetaAndCheck(folder) } diff --git a/lib/model/folder.go b/lib/model/folder.go index c6aab7db9..57b154bb0 100644 --- a/lib/model/folder.go +++ b/lib/model/folder.go @@ -28,6 +28,7 @@ import ( "github.com/syncthing/syncthing/lib/scanner" "github.com/syncthing/syncthing/lib/stats" "github.com/syncthing/syncthing/lib/sync" + "github.com/syncthing/syncthing/lib/util" "github.com/syncthing/syncthing/lib/watchaggregator" "github.com/thejerf/suture" @@ -330,7 +331,7 @@ func (f *folder) pull() (success bool) { // Pulling failed, try again later. delay := f.pullPause + time.Since(startTime) - l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), delay.Truncate(time.Second)) + l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), util.NiceDurationString(delay)) f.pullFailTimer.Reset(delay) return false } diff --git a/lib/util/utils.go b/lib/util/utils.go index 301496c89..2817b67c8 100644 --- a/lib/util/utils.go +++ b/lib/util/utils.go @@ -14,6 +14,7 @@ import ( "reflect" "strconv" "strings" + "time" "github.com/syncthing/syncthing/lib/sync" @@ -314,3 +315,19 @@ func CallWithContext(ctx context.Context, fn func() error) error { return ctx.Err() } } + +func NiceDurationString(d time.Duration) string { + switch { + case d > 24*time.Hour: + d = d.Round(time.Hour) + case d > time.Hour: + d = d.Round(time.Minute) + case d > time.Minute: + d = d.Round(time.Second) + case d > time.Second: + d = d.Round(time.Millisecond) + case d > time.Millisecond: + d = d.Round(time.Microsecond) + } + return d.String() +}