mirror of https://gitlab.com/bashrc2/epicyon
Don't exit until all file extensions are tried
parent
33a5decd1d
commit
666a3f9680
26
daemon.py
26
daemon.py
|
@ -1916,35 +1916,37 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
for bg in ('follow', 'options', 'login'):
|
for bg in ('follow', 'options', 'login'):
|
||||||
# follow screen background image
|
# follow screen background image
|
||||||
if self.path == '/' + bg + '-background.' + ext:
|
if self.path == '/' + bg + '-background.' + ext:
|
||||||
mediaFilename = \
|
bgFilename = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
self.server.baseDir + '/accounts/' + \
|
||||||
bg + '-background.' + ext
|
bg + '-background.' + ext
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(bgFilename):
|
||||||
if self._etag_exists(mediaFilename):
|
if self._etag_exists(bgFilename):
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
self._304()
|
self._304()
|
||||||
return
|
return
|
||||||
|
|
||||||
tries = 0
|
tries = 0
|
||||||
mediaBinary = None
|
bgBinary = None
|
||||||
while tries < 5:
|
while tries < 5:
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
with open(bgFilename, 'rb') as avFile:
|
||||||
mediaBinary = avFile.read()
|
bgBinary = 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 bgBinary:
|
||||||
self._set_headers_etag(mediaFilename,
|
if ext == 'jpg':
|
||||||
|
ext = 'jpeg'
|
||||||
|
self._set_headers_etag(bgFilename,
|
||||||
'image/' + ext,
|
'image/' + ext,
|
||||||
mediaBinary, cookie,
|
bgBinary, cookie,
|
||||||
callingDomain)
|
callingDomain)
|
||||||
self._write(mediaBinary)
|
self._write(bgBinary)
|
||||||
return
|
return
|
||||||
self._404()
|
self._404()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 18)
|
self._benchmarkGETtimings(GETstartTime, GETtimings, 18)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue