From c4611e29864d207a05e9face5500c2b4400a0b6d Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 15 Nov 2022 20:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E8=BE=B9=E7=BC=98=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=9C=89=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=97=B6=E6=89=8D=E4=BC=9A=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_cache_policy.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/serverconfigs/http_cache_policy.go b/pkg/serverconfigs/http_cache_policy.go index 1157cb1..a73af9d 100644 --- a/pkg/serverconfigs/http_cache_policy.go +++ b/pkg/serverconfigs/http_cache_policy.go @@ -84,6 +84,10 @@ func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool { // UpdateDiskDir 修改文件路径 func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) { if this.Type == CachePolicyStorageFile { + if len(dir) == 0 && len(subDirs) == 0 { + return + } + oldOptionsJSON, err := json.Marshal(this.Options) if err != nil { return @@ -95,8 +99,12 @@ func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) { return } - options.Dir = dir - options.SubDirs = subDirs + if len(dir) > 0 { + options.Dir = dir + } + if len(subDirs) > 0 { + options.SubDirs = subDirs + } newOptionsJSON, err := json.Marshal(options) if err != nil {