From d9c20676a06db5ff2535c2064b22a0f4f251a436 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 25 Jul 2020 23:42:07 +0100 Subject: [PATCH] Extra condition --- daemon.py | 65 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/daemon.py b/daemon.py index 13195cbe..a8392991 100644 --- a/daemon.py +++ b/daemon.py @@ -1911,39 +1911,40 @@ class PubServer(BaseHTTPRequestHandler): self._benchmarkGETtimings(GETstartTime, GETtimings, 17) - for ext in ('webp', 'gif', 'jpg', 'png'): - for bg in ('follow', 'options', 'login'): - # follow screen background image - if self.path == '/' + bg + '-background.' + ext: - mediaFilename = \ - self.server.baseDir + '/accounts/' + \ - bg + '-background.' + ext - if os.path.isfile(mediaFilename): - if self._etag_exists(mediaFilename): - # The file has not changed - self._304() - return + if '-background.' in self.path: + for ext in ('webp', 'gif', 'jpg', 'png'): + for bg in ('follow', 'options', 'login'): + # follow screen background image + if self.path == '/' + bg + '-background.' + ext: + mediaFilename = \ + self.server.baseDir + '/accounts/' + \ + bg + '-background.' + ext + if os.path.isfile(mediaFilename): + if self._etag_exists(mediaFilename): + # The file has not changed + self._304() + return - tries = 0 - mediaBinary = None - while tries < 5: - try: - with open(mediaFilename, 'rb') as avFile: - mediaBinary = avFile.read() - break - except Exception as e: - print(e) - time.sleep(1) - tries += 1 - if mediaBinary: - self._set_headers_etag(mediaFilename, - 'image/' + ext, - mediaBinary, cookie, - callingDomain) - self._write(mediaBinary) - return - self._404() - return + tries = 0 + mediaBinary = None + while tries < 5: + try: + with open(mediaFilename, 'rb') as avFile: + mediaBinary = avFile.read() + break + except Exception as e: + print(e) + time.sleep(1) + tries += 1 + if mediaBinary: + self._set_headers_etag(mediaFilename, + 'image/' + ext, + mediaBinary, cookie, + callingDomain) + self._write(mediaBinary) + return + self._404() + return self._benchmarkGETtimings(GETstartTime, GETtimings, 18)