From cd8bd25a302426fa319de188fb6535cc8c71de14 Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Thu, 10 Sep 2020 15:26:47 +0200
Subject: [PATCH] [code][models] Ensure binary read is used when handling a CXX
 instance

It is done so currently as Databases are not Code contributions
since they have no owner.
---
 beat/web/code/models.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/beat/web/code/models.py b/beat/web/code/models.py
index 301baa035..57f6c5116 100755
--- a/beat/web/code/models.py
+++ b/beat/web/code/models.py
@@ -221,7 +221,10 @@ def set_source_code(instance, value):
 
 
 def get_source_code(instance):
-    return storage.get_file_content(instance, "source_code_file")
+    binary = False
+    if isinstance(instance, Code):
+        binary = instance.is_binary()
+    return storage.get_file_content(instance, "source_code_file", binary)
 
 
 # ----------------------------------------------------------
-- 
GitLab