fix: Handle decode error when getting value from cache

This commit is contained in:
Faris Ansari 2021-05-18 13:40:47 +05:30
parent d90660affe
commit dc04fe9ed6

View file

@ -803,6 +803,11 @@ def get_assets_json():
cache = frappe.cache() cache = frappe.cache()
# using .get instead of .get_value to avoid pickle.loads # using .get instead of .get_value to avoid pickle.loads
assets_json = cache.get("assets_json") assets_json = cache.get("assets_json")
try:
assets_json = assets_json.decode('utf-8')
except UnicodeDecodeError:
assets_json = None
if not assets_json: if not assets_json:
assets_json = frappe.read_file("assets/frappe/dist/assets.json") assets_json = frappe.read_file("assets/frappe/dist/assets.json")
cache.set_value("assets_json", assets_json, shared=True) cache.set_value("assets_json", assets_json, shared=True)