From e922c12611c2ef0071c3c3aa61883793c8787563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 12 Jan 2024 14:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E6=97=A0=E6=B3=95=E5=88=87=E6=8D=A2=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E5=86=85=E5=AD=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 9 +++++++++ internal/caches/storage_memory.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 3e8cfc8..74fa32c 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -111,6 +111,15 @@ func (this *FileStorage) Policy() *serverconfigs.HTTPCachePolicy { // CanUpdatePolicy 检查策略是否可以更新 func (this *FileStorage) CanUpdatePolicy(newPolicy *serverconfigs.HTTPCachePolicy) bool { + if newPolicy == nil { + return false + } + + // 检查类型 + if newPolicy.Type != serverconfigs.CachePolicyStorageFile { + return false + } + // 检查路径是否有变化 oldOptionsJSON, err := json.Marshal(this.policy.Options) if err != nil { diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index 4c69a0a..1b15765 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -366,7 +366,7 @@ func (this *MemoryStorage) UpdatePolicy(newPolicy *serverconfigs.HTTPCachePolicy // CanUpdatePolicy 检查策略是否可以更新 func (this *MemoryStorage) CanUpdatePolicy(newPolicy *serverconfigs.HTTPCachePolicy) bool { - return true + return newPolicy != nil && newPolicy.Type == serverconfigs.CachePolicyStorageMemory } // AddToList 将缓存添加到列表