From 54c885f1ad9ead0e154dfebfb486e671f581c4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 5 Apr 2019 10:24:19 +0200 Subject: [PATCH] =?UTF-8?q?=E2=98=94=20Prevent=20issues=20if=20hash=20is?= =?UTF-8?q?=20n/a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently it can happen that no hash is available for an STL file. See SERVER-TQ in Sentry. So let's be a bit more careful here. Closes #3107 --- src/octoprint/filemanager/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 8521e814e..24e8b1f90 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -337,13 +337,13 @@ class FileManager(object): gcode_location=dest_location)) else: source_meta = self.get_metadata(source_location, source_path) - hash = source_meta["hash"] + hash = source_meta.get("hash", "n/a") import io links = [("model", dict(name=source_path))] _, stl_name = self.split_path(source_location, source_path) file_obj = StreamWrapper(os.path.basename(dest_path), - io.BytesIO(u";Generated from {stl_name} {hash}\n".format(**locals()).encode("ascii", "replace")), + io.BytesIO(u";Generated from {stl_name} (hash: {hash})\n".format(**locals()).encode("ascii", "replace")), io.FileIO(tmp_path, "rb")) printer_profile = self._printer_profile_manager.get(printer_profile_id)