From 325c1bdb1763672043f1c20be6cf01b47102d732 Mon Sep 17 00:00:00 2001 From: Jigar-f Date: Fri, 13 Dec 2024 12:38:04 +0530 Subject: [PATCH] Create fronted cache if not found. --- proxied/fronted.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/proxied/fronted.go b/proxied/fronted.go index 9f052cb50..90e493e91 100644 --- a/proxied/fronted.go +++ b/proxied/fronted.go @@ -20,6 +20,18 @@ func newFronted() fronted.Fronted { log.Errorf("Unable to get user config dir: %v", err) } else { cacheFile = filepath.Join(dir, common.DefaultAppName, "fronted_cache.json") + if err := os.MkdirAll(filepath.Dir(cacheFile), 0755); err != nil { + log.Errorf("Failed to create directory: %v", err) + } + _, error := os.Stat(cacheFile) + if error != nil { + log.Debugf("Cache file not found at: %v", cacheFile) + _, err := os.Create(cacheFile) + log.Debugf("Cache file created at: %v", cacheFile) + if err != nil { + log.Errorf("Unable to create cache file: %v", err) + } + } } return fronted.NewFronted(cacheFile) }