Skip to content

Commit

Permalink
Move matcher to outside to avoid fatal error: concurrent map read and…
Browse files Browse the repository at this point in the history
… map write (#250)

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

* Bump to 0.9.3
  • Loading branch information
n0vad3v authored Jul 6, 2023
1 parent 773424c commit a5e3282
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down
3 changes: 2 additions & 1 deletion helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit a5e3282

Please sign in to comment.