Move 'get_project_base_directory' to common directory (#10940)

### What problem does this PR solve?

As title

### Type of change

- [x] Refactoring

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2025-11-02 21:05:28 +08:00
committed by GitHub
parent 57a83eca8a
commit 44f2d6f5da
24 changed files with 186 additions and 51 deletions

View File

@ -23,6 +23,7 @@ import pickle
import importlib
from api.utils import file_utils
from common.file_utils import get_project_base_directory
from filelock import FileLock
from api.utils.common import bytes_to_string, string_to_bytes
from api.constants import SERVICE_CONF
@ -30,7 +31,7 @@ from api.constants import SERVICE_CONF
def conf_realpath(conf_name):
conf_path = f"conf/{conf_name}"
return os.path.join(file_utils.get_project_base_directory(), conf_path)
return os.path.join(get_project_base_directory(), conf_path)
def read_config(conf_name=SERVICE_CONF):
@ -129,8 +130,7 @@ def decrypt_database_config(
def update_config(key, value, conf_name=SERVICE_CONF):
conf_path = conf_realpath(conf_name=conf_name)
if not os.path.isabs(conf_path):
conf_path = os.path.join(
file_utils.get_project_base_directory(), conf_path)
conf_path = os.path.join(get_project_base_directory(), conf_path)
with FileLock(os.path.join(os.path.dirname(conf_path), ".lock")):
config = file_utils.load_yaml_conf(conf_path=conf_path) or {}