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

View File

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