From ae16dcc16a74cf26fb36738545950975e4e6cca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 14 Apr 2020 15:40:23 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Warn=20if=20we=20should=20use=20.gz?= =?UTF-8?q?=20asset=20but=20can't?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't silently fail. Should rarely happen anyhow but would indicate issue with install or setup. As noted by @flaviut in comment on fde070665d9cb48a1c59af787fa3082bb6dd4941 --- src/octoprint/server/util/tornado.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 880910bb6..0d15fa4b2 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -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)