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,12 +1315,19 @@ 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 os.path.isfile(mediaFilename): if self.server.iconsCache.get(mediaStr):
with open(mediaFilename, 'rb') as avFile: self._set_headers('image/png',len(mediaBinary),cookie)
mediaBinary = avFile.read() self._write(mediaBinary)
self._set_headers('image/png',len(mediaBinary),cookie) self.server.iconsCache[mediaStr]=mediaBinary
self._write(mediaBinary)
return return
else:
if os.path.isfile(mediaFilename):
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
self._set_headers('image/png',len(mediaBinary),cookie)
self._write(mediaBinary)
self.server.iconsCache[mediaStr]=mediaBinary
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= \