From 68f6ff2a002f9a805feb40342979e3a8bef763a9 Mon Sep 17 00:00:00 2001 From: Changxin Miao Date: Fri, 27 Sep 2024 22:13:10 +0800 Subject: [PATCH] Fix warning log when creating a new cache dir Signed-off-by: Changxin Miao --- pkg/chunk/disk_cache.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/chunk/disk_cache.go b/pkg/chunk/disk_cache.go index 43e5a808e3f9..2da59e6d8d12 100644 --- a/pkg/chunk/disk_cache.go +++ b/pkg/chunk/disk_cache.go @@ -497,6 +497,9 @@ func (cache *cacheStore) createDir(dir string) { var st os.FileInfo var err error if st, err = os.Stat(dir); os.IsNotExist(err) { + if len(dir) > 1 && strings.HasSuffix(dir, string(filepath.Separator)) { + dir = dir[:len(dir)-1] // CacheManager appends "/" to dir, remove it so that `filepath.Dir` returns the parent dir + } if filepath.Dir(dir) != dir { cache.createDir(filepath.Dir(dir)) }