From 2e2002668b00fc238debc31cdd1b314fa79f288c Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Fri, 8 Jan 2021 22:14:14 +0800 Subject: [PATCH] fix video --- coolq/cqcode.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index c2d250e..ec69ef2 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -878,22 +878,23 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) ( } hash := md5.Sum([]byte(f)) cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache") - if global.PathExists(cacheFile) && cache == "1" { - return &LocalImageElement{File: cacheFile}, nil - } - if global.PathExists(cacheFile) { - _ = os.Remove(cacheFile) - } - thread, _ := strconv.Atoi(c) var maxSize = func() int64 { if video { return maxVideoSize } return maxImageSize }() + thread, _ := strconv.Atoi(c) + if global.PathExists(cacheFile) && cache == "1" { + goto hasCacheFile + } + if global.PathExists(cacheFile) { + _ = os.Remove(cacheFile) + } if err := global.DownloadFileMultiThreading(f, cacheFile, maxSize, thread, nil); err != nil { return nil, err } + hasCacheFile: if video { return &LocalVideoElement{ File: cacheFile,