From bb3e86fbd5b2e0ec17b496a3ca3904cd63ce0521 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 8 Jun 2020 08:49:57 -0700 Subject: [PATCH] auto create non-existing cache directory fix https://github.com/chrislusf/seaweedfs/issues/1350 --- weed/filesys/wfs.go | 1 + weed/util/file_util.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 67dd2a62c..2b0ef64c2 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -89,6 +89,7 @@ func NewSeaweedFileSystem(option *Option) *WFS { }, } if option.CacheSizeMB > 0 { + os.MkdirAll(option.CacheDir, 0755) wfs.chunkCache = chunk_cache.NewChunkCache(256, option.CacheDir, option.CacheSizeMB) grace.OnInterrupt(func() { wfs.chunkCache.Shutdown() diff --git a/weed/util/file_util.go b/weed/util/file_util.go index bef9f7cd6..ff725830b 100644 --- a/weed/util/file_util.go +++ b/weed/util/file_util.go @@ -49,6 +49,10 @@ func CheckFile(filename string) (exists, canRead, canWrite bool, modTime time.Ti exists = false return } + if err != nil { + glog.Errorf("check %s: %v", filename, err) + return + } if fi.Mode()&0400 != 0 { canRead = true }