Create khoj config dir if non-existant, before writing to khoj env file

This commit is contained in:
Debanjum Singh Solanky
2023-07-30 01:35:36 -07:00
parent 56394d2879
commit 53810a0ff7

View File

@@ -6,6 +6,7 @@ from importlib import import_module
from importlib.metadata import version from importlib.metadata import version
import logging import logging
from os import path from os import path
import os
from pathlib import Path from pathlib import Path
import platform import platform
import sys import sys
@@ -169,6 +170,9 @@ def get_server_id():
# If server_id is not found, generate a new one # If server_id is not found, generate a new one
server_id = str(uuid.uuid4()) server_id = str(uuid.uuid4())
# Create khoj config directory if it doesn't exist
os.makedirs(path.dirname(app_env_filename), exist_ok=True)
# Write the server_id to the env file # Write the server_id to the env file
with open(app_env_filename, "w") as f: with open(app_env_filename, "w") as f:
f.write("server_id=" + server_id + "\n") f.write("server_id=" + server_id + "\n")