]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Don't do decoding work if not needed 1967/head
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Fri, 11 Nov 2022 18:09:56 +0000 (10:09 -0800)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Fri, 11 Nov 2022 18:09:56 +0000 (10:09 -0800)
src/documents/consumer.py

index 45722d01a4470b1b9875a9c6edfaa098d4981ccf..75181cabb0183fbf4a4fcbf452549ad177741b03 100644 (file)
@@ -537,27 +537,27 @@ class Consumer(LoggingMixin):
         )
 
         # Decode the output (if any)
-        stdout_str = (
-            completed_process.stdout.decode("utf8", errors="ignore")
-            .strip()
-            .split(
-                "\n",
-            )
-        )
-        stderr_str = (
-            completed_process.stderr.decode("utf8", errors="ignore")
-            .strip()
-            .split(
-                "\n",
+        if len(completed_process.stdout):
+            stdout_str = (
+                completed_process.stdout.decode("utf8", errors="ignore")
+                .strip()
+                .split(
+                    "\n",
+                )
             )
-        )
-
-        if len(stdout_str):
             self.log("info", "Script stdout:")
             for line in stdout_str:
                 self.log("info", line)
 
-        if len(stderr_str):
+        if len(completed_process.stderr):
+            stderr_str = (
+                completed_process.stderr.decode("utf8", errors="ignore")
+                .strip()
+                .split(
+                    "\n",
+                )
+            )
+
             self.log("warning", "Script stderr:")
             for line in stderr_str:
                 self.log("warning", line)