♻ Warn if we should use .gz asset but can't

Don't silently fail. Should rarely happen anyhow but would indicate
issue with install or setup.

As noted by @flaviut in comment on fde070665d
This commit is contained in:
Gina Häußge committed 2020-04-14 15:40:23 +02:00
1 parent d513459c63
commit ae16dcc16a
1 file changed
+7 -3
+7 -3
View File
@@ -983,9 +983,13 @@ class LargeResponseHandler(RequestlessExceptionLoggingMixin,
if "cookie" in self.request.arguments:
self.set_cookie(self.request.arguments["cookie"][0], "true", path="/")
if self.should_use_precompressed() and os.path.exists(os.path.join(self.root, path + ".gz")):
self.set_header("Content-Encoding", "gzip")
path = path + ".gz"
if self.should_use_precompressed():
if os.path.exists(os.path.join(self.root, path + ".gz")):
self.set_header("Content-Encoding", "gzip")
path = path + ".gz"
else:
logging.getLogger(__name__).warn("Precompressed assets expected but {}.gz does not exist "
"in {}, using plain file instead.".format(path, self.root))
return tornado.web.StaticFileHandler.get(self, path, include_body=include_body)