只有边缘节点有自定义缓存目录时才会更新缓存策略

This commit is contained in:
GoEdgeLab
2022-11-15 20:40:59 +08:00
parent 4dd013dfeb
commit c4611e2986

View File

@@ -84,6 +84,10 @@ func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool {
// UpdateDiskDir 修改文件路径 // UpdateDiskDir 修改文件路径
func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) { func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) {
if this.Type == CachePolicyStorageFile { if this.Type == CachePolicyStorageFile {
if len(dir) == 0 && len(subDirs) == 0 {
return
}
oldOptionsJSON, err := json.Marshal(this.Options) oldOptionsJSON, err := json.Marshal(this.Options)
if err != nil { if err != nil {
return return
@@ -95,8 +99,12 @@ func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) {
return return
} }
if len(dir) > 0 {
options.Dir = dir options.Dir = dir
}
if len(subDirs) > 0 {
options.SubDirs = subDirs options.SubDirs = subDirs
}
newOptionsJSON, err := json.Marshal(options) newOptionsJSON, err := json.Marshal(options)
if err != nil { if err != nil {