Move matcher to outside to avoid fatal error: concurrent map read and map write (#250)

* Move matcher to outside to avoid fatal error: concurrent map read and map write

* Bump to 0.9.3
This commit is contained in:
Nova Kwok 2023-07-06 22:16:24 +08:00 committed by GitHub
parent 773424ca01
commit a5e3282ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -59,7 +59,7 @@ var (
ProxyMode bool
Prefetch bool
Config jsonFile
Version = "0.9.2"
Version = "0.9.3"
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
)

View File

@ -17,6 +17,8 @@ import (
log "github.com/sirupsen/logrus"
)
var _ = filetype.AddMatcher(filetype.NewType("avif", "image/avif"), avifMatcher)
func avifMatcher(buf []byte) bool {
// use hexdump on macOS to see the magic number
// 0000001c 66747970 61766966 00000000 61766966 6d696631 6d696166
@ -34,7 +36,6 @@ func avifMatcher(buf []byte) bool {
}
func GetFileContentType(buffer []byte) string {
filetype.AddMatcher(filetype.NewType("avif", "image/avif"), avifMatcher)
kind, _ := filetype.Match(buffer)
return kind.MIME.Value
}