From 666a3f9680496ac4e541c2bcb98790326eadd7a7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 26 Jul 2020 10:15:51 +0100 Subject: [PATCH] Don't exit until all file extensions are tried --- daemon.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/daemon.py b/daemon.py index a8392991b..29f222094 100644 --- a/daemon.py +++ b/daemon.py @@ -1916,35 +1916,37 @@ class PubServer(BaseHTTPRequestHandler): for bg in ('follow', 'options', 'login'): # follow screen background image if self.path == '/' + bg + '-background.' + ext: - mediaFilename = \ + bgFilename = \ self.server.baseDir + '/accounts/' + \ bg + '-background.' + ext - if os.path.isfile(mediaFilename): - if self._etag_exists(mediaFilename): + if os.path.isfile(bgFilename): + if self._etag_exists(bgFilename): # The file has not changed self._304() return tries = 0 - mediaBinary = None + bgBinary = None while tries < 5: try: - with open(mediaFilename, 'rb') as avFile: - mediaBinary = avFile.read() + with open(bgFilename, 'rb') as avFile: + bgBinary = avFile.read() break except Exception as e: print(e) time.sleep(1) tries += 1 - if mediaBinary: - self._set_headers_etag(mediaFilename, + if bgBinary: + if ext == 'jpg': + ext = 'jpeg' + self._set_headers_etag(bgFilename, 'image/' + ext, - mediaBinary, cookie, + bgBinary, cookie, callingDomain) - self._write(mediaBinary) + self._write(bgBinary) return - self._404() - return + self._404() + return self._benchmarkGETtimings(GETstartTime, GETtimings, 18)