From 77530f13ee29993f1f29f0030c0e88d18402388d Mon Sep 17 00:00:00 2001 From: shortcutme Date: Wed, 20 Mar 2019 00:48:51 +0100 Subject: [PATCH] Fix content.json update and verify on Python 3.5 --- src/Content/ContentManager.py | 6 +++++- src/File/FileRequest.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Content/ContentManager.py b/src/Content/ContentManager.py index c32062e7..c7f3635e 100644 --- a/src/Content/ContentManager.py +++ b/src/Content/ContentManager.py @@ -4,6 +4,7 @@ import re import os import copy import base64 +import sys import gevent @@ -901,7 +902,10 @@ class ContentManager(object): if type(file) is dict: new_content = file else: - new_content = json.load(file) + if sys.version_info.major == 3 and sys.version_info.minor < 6: + new_content = json.loads(file.read().decode("utf8")) + else: + new_content = json.load(file) if inner_path in self.contents: old_content = self.contents.get(inner_path, {"modified": 0}) # Checks if its newer the ours diff --git a/src/File/FileRequest.py b/src/File/FileRequest.py index 6dc845da..f316c5f2 100644 --- a/src/File/FileRequest.py +++ b/src/File/FileRequest.py @@ -117,7 +117,7 @@ class FileRequest(object): return try: - content = json.loads(params["body"]) + content = json.loads(params["body"].decode()) except Exception as err: self.log.debug("Update for %s is invalid JSON: %s" % (inner_path, err)) self.response({"error": "File invalid JSON"})