mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	@@ -33,7 +33,7 @@ type imageCache struct {
 | 
			
		||||
 | 
			
		||||
func (c *imageCache) isInCache(key string) bool {
 | 
			
		||||
	c.mu.RLock()
 | 
			
		||||
	_, found := c.store[key]
 | 
			
		||||
	_, found := c.store[c.normalizeKey(key)]
 | 
			
		||||
	c.mu.RUnlock()
 | 
			
		||||
	return found
 | 
			
		||||
}
 | 
			
		||||
@@ -41,6 +41,7 @@ func (c *imageCache) isInCache(key string) bool {
 | 
			
		||||
func (c *imageCache) deleteByPrefix(prefix string) {
 | 
			
		||||
	c.mu.Lock()
 | 
			
		||||
	defer c.mu.Unlock()
 | 
			
		||||
	prefix = c.normalizeKey(prefix)
 | 
			
		||||
	for k := range c.store {
 | 
			
		||||
		if strings.HasPrefix(k, prefix) {
 | 
			
		||||
			delete(c.store, k)
 | 
			
		||||
@@ -48,6 +49,16 @@ func (c *imageCache) deleteByPrefix(prefix string) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *imageCache) normalizeKey(key string) string {
 | 
			
		||||
	// It is a path with Unix style slashes and it always starts with a leading slash.
 | 
			
		||||
	key = filepath.ToSlash(key)
 | 
			
		||||
	if !strings.HasPrefix(key, "/") {
 | 
			
		||||
		key = "/" + key
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return key
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *imageCache) clear() {
 | 
			
		||||
	c.mu.Lock()
 | 
			
		||||
	defer c.mu.Unlock()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user