Update db.py

Ensure directory exists before attempting to write file in db.py
This commit is contained in:
Ryan Jalynski
2023-06-16 19:01:27 -04:00
committed by GitHub
parent 25a6c31d4f
commit 6f63b8039d

View File

@@ -15,6 +15,9 @@ class DB:
return f.read()
def __setitem__(self, key, val):
# Ensure the directory exists
os.makedirs(self.path, exist_ok=True)
with open(self.path / key, 'w', encoding='utf-8') as f:
f.write(val)