mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-01-06 11:55:48 +08:00
节点可以单独设置缓存目录
This commit is contained in:
@@ -80,3 +80,35 @@ func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool {
|
||||
}
|
||||
return bytes.Equal(policyJSON1, policyJSON2)
|
||||
}
|
||||
|
||||
// UpdateDiskDir 修改文件路径
|
||||
func (this *HTTPCachePolicy) UpdateDiskDir(dir string) {
|
||||
if this.Type == CachePolicyStorageFile {
|
||||
oldOptionsJSON, err := json.Marshal(this.Options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var options = &HTTPFileCacheStorage{}
|
||||
err = json.Unmarshal(oldOptionsJSON, options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if options.Dir != dir {
|
||||
options.Dir = dir
|
||||
|
||||
newOptionsJSON, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var newOptionsMap = map[string]interface{}{}
|
||||
err = json.Unmarshal(newOptionsJSON, &newOptionsMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
this.Options = newOptionsMap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user