From cfc92b2284d700a1f3b08134689ff4de356e31ac Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Fri, 6 Dec 2019 07:30:39 +0100
Subject: [PATCH] Bug: The log stream from docker can be str or bytes

We don't know why this is the case..
---
 src/restic_compose_backup/backup_runner.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/restic_compose_backup/backup_runner.py b/src/restic_compose_backup/backup_runner.py
index d8fb33c..a1b37a1 100644
--- a/src/restic_compose_backup/backup_runner.py
+++ b/src/restic_compose_backup/backup_runner.py
@@ -35,7 +35,13 @@ def run(image: str = None, command: str = None, volumes: dict = None,
             line = ""
             while True:
                 try:
-                    line += next(stream).decode()
+                    # TODO: figure out why..
+                    # Apparently the stream can be bytes or strings.
+                    data = next(stream)
+                    if isinstance(data, bytes):
+                        line += data.decode()
+                    elif isinstance(data, str):
+                        line += data
                     if line.endswith('\n'):
                         break
                 except StopIteration: