Caching of icons

main
Bob Mottram 2019-11-24 18:06:54 +00:00
parent 155761a3c5
commit 5a63454d1b
1 changed files with 14 additions and 5 deletions

View File

@ -1315,11 +1315,18 @@ class PubServer(BaseHTTPRequestHandler):
mediaStr=self.path.split('/icons/')[1] mediaStr=self.path.split('/icons/')[1]
mediaFilename= \ mediaFilename= \
self.server.baseDir+'/img/icons/'+mediaStr self.server.baseDir+'/img/icons/'+mediaStr
if self.server.iconsCache.get(mediaStr):
self._set_headers('image/png',len(mediaBinary),cookie)
self._write(mediaBinary)
self.server.iconsCache[mediaStr]=mediaBinary
return
else:
if os.path.isfile(mediaFilename): if os.path.isfile(mediaFilename):
with open(mediaFilename, 'rb') as avFile: with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read() mediaBinary = avFile.read()
self._set_headers('image/png',len(mediaBinary),cookie) self._set_headers('image/png',len(mediaBinary),cookie)
self._write(mediaBinary) self._write(mediaBinary)
self.server.iconsCache[mediaStr]=mediaBinary
return return
self._404() self._404()
return return
@ -3868,6 +3875,7 @@ class PubServer(BaseHTTPRequestHandler):
actorChanged=True actorChanged=True
if fields.get('themeDropdown'): if fields.get('themeDropdown'):
setTheme(self.server.baseDir,fields['themeDropdown']) setTheme(self.server.baseDir,fields['themeDropdown'])
#self.server.iconsCache={}
if fields.get('donateUrl'): if fields.get('donateUrl'):
currentDonateUrl=getDonationUrl(actorJson) currentDonateUrl=getDonationUrl(actorJson)
if fields['donateUrl']!=currentDonateUrl: if fields['donateUrl']!=currentDonateUrl:
@ -5324,6 +5332,7 @@ def runDaemon(maxRecentPosts: int, \
httpd.recentPostsCache={} httpd.recentPostsCache={}
httpd.maxRecentPosts=maxRecentPosts httpd.maxRecentPosts=maxRecentPosts
httpd.iconsCache={}
print('Creating inbox queue') print('Creating inbox queue')
httpd.thrInboxQueue= \ httpd.thrInboxQueue= \