mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
/browse: Cache top level resized icons
This commit is contained in:
parent
40808b4a1b
commit
9181d87588
@ -262,6 +262,12 @@ class BrowseServer(object):
|
||||
|
||||
# Catalogs {{{
|
||||
def browse_icon(self, name='blank.png'):
|
||||
cherrypy.response.headers['Content-Type'] = 'image/png'
|
||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time)
|
||||
|
||||
if not hasattr(self, '__browse_icon_cache__'):
|
||||
self.__browse_icon_cache__ = {}
|
||||
if name not in self.__browse_icon_cache__:
|
||||
try:
|
||||
data = I(name, data=True)
|
||||
except:
|
||||
@ -272,10 +278,9 @@ class BrowseServer(object):
|
||||
scaled, width, height = fit_image(width, height, 48, 48)
|
||||
if scaled:
|
||||
img.size = (width, height)
|
||||
cherrypy.response.headers['Content-Type'] = 'image/png'
|
||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time)
|
||||
|
||||
return img.export('png')
|
||||
self.__browse_icon_cache__[name] = img.export('png')
|
||||
return self.__browse_icon_cache__[name]
|
||||
|
||||
def browse_toplevel(self):
|
||||
categories = self.categories_cache()
|
||||
|
Loading…
x
Reference in New Issue
Block a user