mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-29 02:50:29 +00:00
0a14297b48
we need my custom golang/x/net/webdav fork for now https://github.com/drakkan/net/tree/sftpgo
35 lines
506 B
Go
35 lines
506 B
Go
package webdavd
|
|
|
|
import "sync"
|
|
|
|
type mimeCache struct {
|
|
maxSize int
|
|
sync.RWMutex
|
|
mimeTypes map[string]string
|
|
}
|
|
|
|
var mimeTypeCache mimeCache
|
|
|
|
func (c *mimeCache) addMimeToCache(key, value string) {
|
|
c.Lock()
|
|
defer c.Unlock()
|
|
|
|
if key == "" || value == "" {
|
|
return
|
|
}
|
|
|
|
if len(c.mimeTypes) >= c.maxSize {
|
|
return
|
|
}
|
|
c.mimeTypes[key] = value
|
|
}
|
|
|
|
func (c *mimeCache) getMimeFromCache(key string) string {
|
|
c.RLock()
|
|
defer c.RUnlock()
|
|
|
|
if val, ok := c.mimeTypes[key]; ok {
|
|
return val
|
|
}
|
|
return ""
|
|
}
|