mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
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:
parent
773424ca01
commit
a5e3282ea1
@ -59,7 +59,7 @@ var (
|
|||||||
ProxyMode bool
|
ProxyMode bool
|
||||||
Prefetch bool
|
Prefetch bool
|
||||||
Config jsonFile
|
Config jsonFile
|
||||||
Version = "0.9.2"
|
Version = "0.9.3"
|
||||||
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
|
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = filetype.AddMatcher(filetype.NewType("avif", "image/avif"), avifMatcher)
|
||||||
|
|
||||||
func avifMatcher(buf []byte) bool {
|
func avifMatcher(buf []byte) bool {
|
||||||
// use hexdump on macOS to see the magic number
|
// use hexdump on macOS to see the magic number
|
||||||
// 0000001c 66747970 61766966 00000000 61766966 6d696631 6d696166
|
// 0000001c 66747970 61766966 00000000 61766966 6d696631 6d696166
|
||||||
@ -34,7 +36,6 @@ func avifMatcher(buf []byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetFileContentType(buffer []byte) string {
|
func GetFileContentType(buffer []byte) string {
|
||||||
filetype.AddMatcher(filetype.NewType("avif", "image/avif"), avifMatcher)
|
|
||||||
kind, _ := filetype.Match(buffer)
|
kind, _ := filetype.Match(buffer)
|
||||||
return kind.MIME.Value
|
return kind.MIME.Value
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user