From 3c9a8a42d9798bce7ac13f154699c5f5048caa17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 5 May 2022 13:12:09 -0400 Subject: [PATCH] more logs --- extern/sector-storage/fsutil/filesize_unix.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extern/sector-storage/fsutil/filesize_unix.go b/extern/sector-storage/fsutil/filesize_unix.go index 7df8dae4c..9c7f04ace 100644 --- a/extern/sector-storage/fsutil/filesize_unix.go +++ b/extern/sector-storage/fsutil/filesize_unix.go @@ -4,6 +4,7 @@ import ( "os" "path/filepath" "syscall" + "time" "golang.org/x/xerrors" ) @@ -15,6 +16,8 @@ type SizeInfo struct { // FileSize returns bytes used by a file or directory on disk // NOTE: We care about the allocated bytes, not file or directory size func FileSize(path string) (SizeInfo, error) { + start := time.Now() + var size int64 err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error { if err != nil { @@ -32,6 +35,11 @@ func FileSize(path string) (SizeInfo, error) { } return err }) + + if time.Now().Sub(start) >= 3*time.Second { + log.Warnw("very slow file size check", "took", time.Now().Sub(start), "path", path) + } + if err != nil { if os.IsNotExist(err) { return SizeInfo{}, os.ErrNotExist