From 637dce0d07b7a41b2062de75d7f3011fe8ae54b0 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Sun, 12 Jul 2020 16:02:27 +0100 Subject: [PATCH] fix: use IEC standard for file sizes --- uploader/checker/age.go | 2 +- uploader/checker/size.go | 8 ++++---- uploader/file.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/uploader/checker/age.go b/uploader/checker/age.go index 715257a..4ecbe73 100644 --- a/uploader/checker/age.go +++ b/uploader/checker/age.go @@ -54,7 +54,7 @@ func (Age) Check(cfg *config.UploaderCheck, log *logrus.Entry, paths []pathutils if checkPassed { log.WithFields(logrus.Fields{ "files_passed": filesPassed, - "files_size": humanize.Bytes(uint64(filesSize)), + "files_size": humanize.IBytes(uint64(filesSize)), }).Info("Local files matching check criteria") } diff --git a/uploader/checker/size.go b/uploader/checker/size.go index 5ff34b9..f028b89 100644 --- a/uploader/checker/size.go +++ b/uploader/checker/size.go @@ -13,11 +13,11 @@ type Size struct{} func (Size) Check(cfg *config.UploaderCheck, log *logrus.Entry, paths []pathutils.Path, size uint64) (*Result, error) { // Check Total Size if size > cfg.Limit { - s := humanize.Bytes(size) + s := humanize.IBytes(size) log.WithFields(logrus.Fields{ - "max_size": humanize.Bytes(cfg.Limit), + "max_size": humanize.IBytes(cfg.Limit), "current_size": s, - "over_size": humanize.Bytes(size - cfg.Limit), + "over_size": humanize.IBytes(size - cfg.Limit), }).Info("Size is greater than specified limit") return &Result{ @@ -28,7 +28,7 @@ func (Size) Check(cfg *config.UploaderCheck, log *logrus.Entry, paths []pathutil return &Result{ Passed: false, - Info: humanize.Bytes(cfg.Limit - size), + Info: humanize.IBytes(cfg.Limit - size), }, nil } diff --git a/uploader/file.go b/uploader/file.go index f3196dc..7cf9161 100644 --- a/uploader/file.go +++ b/uploader/file.go @@ -50,7 +50,7 @@ func (u *Uploader) RefreshLocalFiles() error { // log results u.Log.WithFields(logrus.Fields{ "found_files": len(u.LocalFiles), - "files_size": humanize.Bytes(u.LocalFilesSize), + "files_size": humanize.IBytes(u.LocalFilesSize), "local_folder": u.Config.LocalFolder, }).Info("Refreshed local files")