Extra condition

main
Bob Mottram 2020-07-25 23:42:07 +01:00
parent b4843e1408
commit d9c20676a0
1 changed files with 33 additions and 32 deletions

View File

@ -1911,39 +1911,40 @@ class PubServer(BaseHTTPRequestHandler):
self._benchmarkGETtimings(GETstartTime, GETtimings, 17) self._benchmarkGETtimings(GETstartTime, GETtimings, 17)
for ext in ('webp', 'gif', 'jpg', 'png'): if '-background.' in self.path:
for bg in ('follow', 'options', 'login'): for ext in ('webp', 'gif', 'jpg', 'png'):
# follow screen background image for bg in ('follow', 'options', 'login'):
if self.path == '/' + bg + '-background.' + ext: # follow screen background image
mediaFilename = \ if self.path == '/' + bg + '-background.' + ext:
self.server.baseDir + '/accounts/' + \ mediaFilename = \
bg + '-background.' + ext self.server.baseDir + '/accounts/' + \
if os.path.isfile(mediaFilename): bg + '-background.' + ext
if self._etag_exists(mediaFilename): if os.path.isfile(mediaFilename):
# The file has not changed if self._etag_exists(mediaFilename):
self._304() # The file has not changed
return self._304()
return
tries = 0 tries = 0
mediaBinary = None mediaBinary = None
while tries < 5: while tries < 5:
try: try:
with open(mediaFilename, 'rb') as avFile: with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read() mediaBinary = avFile.read()
break break
except Exception as e: except Exception as e:
print(e) print(e)
time.sleep(1) time.sleep(1)
tries += 1 tries += 1
if mediaBinary: if mediaBinary:
self._set_headers_etag(mediaFilename, self._set_headers_etag(mediaFilename,
'image/' + ext, 'image/' + ext,
mediaBinary, cookie, mediaBinary, cookie,
callingDomain) callingDomain)
self._write(mediaBinary) self._write(mediaBinary)
return return
self._404() self._404()
return return
self._benchmarkGETtimings(GETstartTime, GETtimings, 18) self._benchmarkGETtimings(GETstartTime, GETtimings, 18)