From a289032d05e4a823521ccfce88ff87bf80e09f05 Mon Sep 17 00:00:00 2001 From: Ayush Saini <36878972+imayushsaini@users.noreply.github.com> Date: Sun, 8 May 2022 22:37:47 +0530 Subject: [PATCH] more json fix --- dist/ba_root/mods/playersData/pdata.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py index 7455d29..476b501 100644 --- a/dist/ba_root/mods/playersData/pdata.py +++ b/dist/ba_root/mods/playersData/pdata.py @@ -574,18 +574,22 @@ def load_cache(): get_roles() import shutil +import copy def dump_cache(): if CacheData.profiles!={}: shutil.copyfile(PLAYERS_DATA_PATH + "profiles.json",PLAYERS_DATA_PATH + "profiles.json.backup") + profiles= copy.deepcopy(CacheData.profiles) with open(PLAYERS_DATA_PATH + "profiles.json","w") as f: - json.dump(CacheData.profiles,f,indent=4) + json.dump(profiles,f,indent=4) if CacheData.roles!={}: shutil.copyfile(PLAYERS_DATA_PATH + "roles.json",PLAYERS_DATA_PATH + "roles.json.backup") + roles= copy.deepcopy(CacheData.roles) with open(PLAYERS_DATA_PATH + "roles.json", "w") as f: - json.dump(CacheData.roles, f, indent=4) + json.dump(roles, f, indent=4) if CacheData.custom!={}: shutil.copyfile(PLAYERS_DATA_PATH + "custom.json",PLAYERS_DATA_PATH + "custom.json.backup") + custom= copy.deepcopy(CacheData.custom) with open(PLAYERS_DATA_PATH + "custom.json", "w") as f: - json.dump(CacheData.custom, f, indent=4) + json.dump(custom, f, indent=4) time.sleep(20) dump_cache()