🐛 Remove zero length .gz in case of error

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)
This commit is contained in:
Gina Häußge committed 2020-04-07 19:11:23 +02:00
1 parent 40a0913fa4
commit 5ad06bc602
1 file changed
+6
+6
View File
@@ -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):