From eb94b72bcf6df5d35506711ed6e2a44ba9b7bed6 Mon Sep 17 00:00:00 2001 From: Ayush Saini <36878972+imayushsaini@users.noreply.github.com> Date: Sat, 10 Dec 2022 12:04:08 +0530 Subject: [PATCH] Update pdata.py --- dist/ba_root/mods/playersData/pdata.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py index 37edffb..c3f9b50 100644 --- a/dist/ba_root/mods/playersData/pdata.py +++ b/dist/ba_root/mods/playersData/pdata.py @@ -66,17 +66,22 @@ def get_profiles() -> dict: """ if CacheData.profiles=={}: try: - if os.stat(PLAYERS_DATA_PATH+"profiles.json").st_size > 1000: + if os.stat(PLAYERS_DATA_PATH+"profiles.json").st_size > 1000000: shutil.copyfile(PLAYERS_DATA_PATH + "profiles.json",PLAYERS_DATA_PATH + "profiles.json"+str(datetime.datetime.now())) profiles = {"pb-sdf":{}} + print("resetting profiles") else: f=open(PLAYERS_DATA_PATH + "profiles.json","r") profiles = json.load(f) + f.close() + print("loading old proiles.json") CacheData.profiles=profiles - f.close() - except: + + except Exception as e: f=open(PLAYERS_DATA_PATH + "profiles.json.backup","r") profiles = json.load(f) + print(e) + print("exception happened , falling back to profiles.json.backup") CacheData.profiles=profiles f.close() return profiles