From b4d99f6c13080d2ac2e6f7b29ef0ef2a40b5da62 Mon Sep 17 00:00:00 2001 From: Guiheux Steven <steven.guiheux+github@gmail.com> Date: Tue, 13 Jul 2021 11:17:55 +0200 Subject: [PATCH] fix(cdn): do not compute size from hidden directory (#5883) * fix(cdn): do not compute size from hidden directory * fix: rename status --- engine/cdn/storage/nfs/nfs.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/cdn/storage/nfs/nfs.go b/engine/cdn/storage/nfs/nfs.go index ffc1bf03cb..53aa4a6c31 100644 --- a/engine/cdn/storage/nfs/nfs.go +++ b/engine/cdn/storage/nfs/nfs.go @@ -6,6 +6,7 @@ import ( "io" "os" "path/filepath" + "strings" "time" "github.com/go-gorp/gorp" @@ -185,8 +186,8 @@ func (n *Buffer) Status(_ context.Context) []sdk.MonitoringStatusLine { Status: n.pingStatus, }, { - Component: fmt.Sprintf("storage/%s/redis_dbsize", n.Name()), - Value: fmt.Sprintf("%d keys", n.size), + Component: fmt.Sprintf("storage/%s/size", n.Name()), + Value: fmt.Sprintf("%d octets", n.size), Status: sdk.MonitoringStatusOK, }} } @@ -299,6 +300,7 @@ func (n *Buffer) dirSize() (int64, error) { defer dial.Close() // nolint defer target.Close() // n.pingStatus = sdk.MonitoringStatusOK + return n.computeDirSizeRecursive(target, ".") } @@ -309,7 +311,7 @@ func (n *Buffer) computeDirSizeRecursive(v *gonfs.Target, path string) (int64, e return 0, err } for _, e := range entries { - if e.FileName == "." || e.FileName == ".." { + if strings.HasPrefix(e.FileName, ".") { continue } if e.IsDir() {