From 09280e4178ae3553f586e1954bda69dbf54c8d2b Mon Sep 17 00:00:00 2001 From: Anatole Date: Mon, 21 Oct 2024 01:34:19 +0200 Subject: [PATCH] fix: createdb --- src/utils/dbManager.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/utils/dbManager.py b/src/utils/dbManager.py index ad60b78..92b3317 100644 --- a/src/utils/dbManager.py +++ b/src/utils/dbManager.py @@ -1,9 +1,22 @@ import json +import os, errno DB = "./db/ids.json" +def mkdir_p(path): + try: + os.makedirs(path, exist_ok=True) # Python>3.2 + except TypeError: + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + def __createDB(): """Create a new database file""" + mkdir_p("./db") with open(DB, "w") as f: json.dump({}, f)