From cd6d7221e86b7ef19948776e74b0849a9f95d3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 18 Jun 2022 20:05:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E9=99=90=E5=88=B6206=20Partial=20Cont?= =?UTF-8?q?ent=E4=B8=A4=E6=AC=A1=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index a518e5f..bee5cb2 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -481,11 +481,16 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, siz openFileCache.Close(cachePath) } + // 查询当前已有缓存文件 stat, err := os.Stat(cachePath) - if err == nil && time.Now().Sub(stat.ModTime()) <= 1*time.Second { + + // 检查两次写入缓存的时间是否过于相近,分片内容不受此限制 + if err == nil && !isPartial && time.Now().Sub(stat.ModTime()) <= 1*time.Second { // 防止并发连续写入 return nil, ErrFileIsWriting } + + // 构造文件名 var tmpPath = cachePath var existsFile = false if stat != nil {