1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-08 04:55:55 +08:00

Merge pull request #547 from wdvxdr1123/patch-2

fix video
This commit is contained in:
Mrs4s 2021-01-08 22:18:02 +08:00 committed by GitHub
commit 816c142822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -878,22 +878,23 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
} }
hash := md5.Sum([]byte(f)) hash := md5.Sum([]byte(f))
cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache") 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 { var maxSize = func() int64 {
if video { if video {
return maxVideoSize return maxVideoSize
} }
return maxImageSize 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 { if err := global.DownloadFileMultiThreading(f, cacheFile, maxSize, thread, nil); err != nil {
return nil, err return nil, err
} }
hasCacheFile:
if video { if video {
return &LocalVideoElement{ return &LocalVideoElement{
File: cacheFile, File: cacheFile,