refactor: id.json and logs have been moved to /data

This commit is contained in:
etienne-hd
2026-03-06 18:07:22 +01:00
parent fee4101455
commit b4946264ff
2 changed files with 8 additions and 6 deletions

View File

@@ -16,12 +16,13 @@ class ID:
def _get_ids(self) -> List[str]: def _get_ids(self) -> List[str]:
ids: List[str] = [] ids: List[str] = []
if os.path.exists("id.json"): id_path = os.path.join("data", "id.json")
with open("id.json", "r") as f: if os.path.exists(id_path):
with open(id_path, "r") as f:
try: try:
ids = json.load(f) ids = json.load(f)
except json.JSONDecodeError: except json.JSONDecodeError:
os.remove("id.json") os.remove(id_path)
except: except:
logger.exception("An error occurred while attempting to open the id.json file.") logger.exception("An error occurred while attempting to open the id.json file.")
return ids return ids
@@ -30,9 +31,10 @@ class ID:
return id_ in self._ids return id_ in self._ids
def add(self, id_: str) -> bool: def add(self, id_: str) -> bool:
id_path = os.path.join("data", "id.json")
if not id_ in self._ids: if not id_ in self._ids:
self._ids.append(id_) self._ids.append(id_)
with open("id.json", "w") as f: with open(id_path, "w") as f:
json.dump(self._ids[-MAX_ID:], f, indent=3) json.dump(self._ids[-MAX_ID:], f, indent=3)
self._ids = self._ids[-MAX_ID:] self._ids = self._ids[-MAX_ID:]
return True return True

View File

@@ -4,8 +4,8 @@ from datetime import datetime
# File management # File management
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
file_path: str = os.path.join("logs", f"log_{timestamp}.log") file_path: str = os.path.join("data", "logs", f"log_{timestamp}.log")
os.makedirs("logs", exist_ok=True) os.makedirs(os.path.join("data", "logs"), exist_ok=True)
# Config logging # Config logging
logger = logging.getLogger("lbc-finder") logger = logging.getLogger("lbc-finder")