diff --git a/lbc-finder/searcher/id.py b/lbc-finder/searcher/id.py index 37dacdd..2a3831c 100644 --- a/lbc-finder/searcher/id.py +++ b/lbc-finder/searcher/id.py @@ -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 diff --git a/lbc-finder/searcher/logger.py b/lbc-finder/searcher/logger.py index 9def3bb..788acde 100644 --- a/lbc-finder/searcher/logger.py +++ b/lbc-finder/searcher/logger.py @@ -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")