Skip to content

Commit

Permalink
[0.1.1] handle potential corrupt configs
Browse files Browse the repository at this point in the history
  • Loading branch information
RealistikDash committed Jun 9, 2023
1 parent 9c8d39b commit c54edc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build: fps_bypass/main.py
build: fps_bypass/*.py
pyinstaller --onefile fps_bypass/main.py --name fps_bypass --clean --noconfirm --uac-admin -i "NONE"
12 changes: 10 additions & 2 deletions fps_bypass/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from __future__ import annotations

import json
import logging
import os
from dataclasses import dataclass

CONFIG_VERSION = 1
FPS_CONFIG_DIR = "gfps_bypass"

logger = logging.getLogger("rich")


# NOTE: All future values (after `target_fps`) must have a default value.
@dataclass
Expand Down Expand Up @@ -73,8 +76,13 @@ def read_config() -> Configuration | None:
if not os.path.exists(f"{config_path}\\config.json"):
return None

with open(f"{config_path}\\config.json") as f:
return config_from_json(f.read())
try:
with open(f"{config_path}\\config.json") as f:
return config_from_json(f.read())
except Exception:
logger.debug("Failed to read the config file. Deleting it.", exc_info=True)
delete_config()
return None


def delete_config() -> None:
Expand Down

0 comments on commit c54edc5

Please sign in to comment.