From 8eba9cfea11d22c485e55e8fe95c5def72c553cb Mon Sep 17 00:00:00 2001 From: garmr Date: Tue, 17 Dec 2024 11:19:02 -0800 Subject: [PATCH] create cache directory if it doesn't exist --- cache.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cache.go b/cache.go index 54290a4..6a1de05 100644 --- a/cache.go +++ b/cache.go @@ -14,9 +14,14 @@ func (d *fronted) initCaching(cacheFile string) { func (d *fronted) prepopulateFronts(cacheFile string) { bytes, err := os.ReadFile(cacheFile) + if os.IsNotExist(err) { + if err = os.MkdirAll(filepath.Dir(cacheFile), 0755); err != nil { + log.Errorf("Error creating cache directory: %v", err) + return + } + } if err != nil { - // This is not a big deal since we'll just fill the cache later - log.Debugf("ignorable error: Unable to read cache file for prepopulation: %v", err) + log.Errorf("Error reading cache file: %v", err) return }