From 0f8e89ab979eb8029b9aadb9e9d5e7f8cb598959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 11 Jan 2021 11:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=83=AD=E6=97=B6=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E7=9A=84=E6=9C=80=E5=A4=A7=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/www/.gitignore | 1 - internal/nodes/api_stream.go | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/www/.gitignore b/build/www/.gitignore index 5e46596..e69de29 100644 --- a/build/www/.gitignore +++ b/build/www/.gitignore @@ -1 +0,0 @@ -cache \ No newline at end of file diff --git a/internal/nodes/api_stream.go b/internal/nodes/api_stream.go index 03532be..c1b9ef8 100644 --- a/internal/nodes/api_stream.go +++ b/internal/nodes/api_stream.go @@ -372,8 +372,17 @@ func (this *APIStream) handlePreheatCache(message *pb.NodeStreamMessage) error { _ = resp.Body.Close() }() + // 检查最大内容长度 + maxSize := storage.Policy().MaxSizeBytes() + if maxSize > 0 && resp.ContentLength > maxSize { + locker.Lock() + errorMessages = append(errorMessages, "request failed: the content is too larger than policy setting") + locker.Unlock() + return + } + expiredAt := time.Now().Unix() + 8600 - writer, err := storage.Open(key, expiredAt) // TODO 可以设置缓存过期事件 + writer, err := storage.Open(key, expiredAt) // TODO 可以设置缓存过期时间 if err != nil { locker.Lock() errorMessages = append(errorMessages, "open cache writer failed: "+key+": "+err.Error())