From 5ad06bc6028e367a575970b114b2878a42247a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 7 Apr 2020 19:11:23 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Remove=20zero=20length=20.gz=20i?= =?UTF-8?q?n=20case=20of=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the page won't load at all because the js/css/less files are taken from the gz versions which are empty. Introduced by #3497 TODO: Fix gzip encoding under Python 2 (gzip.compress doesn't exist) --- src/octoprint/server/util/webassets.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/octoprint/server/util/webassets.py b/src/octoprint/server/util/webassets.py index 86c99ba3b..299be0401 100644 --- a/src/octoprint/server/util/webassets.py +++ b/src/octoprint/server/util/webassets.py @@ -7,6 +7,7 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms import logging import gzip +import os import re try: @@ -129,6 +130,11 @@ class GzipFile(Filter): logging.getLogger(__name__).exception("Error writing gzipped " "output of {} to {}".format(output_path, gzipped_output_path)) + try: + os.remove(gzipped_output_path) + except Exception: + logging.getLogger(__name__).exception("Error removing broken " + ".gz from {}".format(gzipped_output_path)) class ChainedHunk(BaseHunk):