core (constants): Use runtime dir:
PID and PB bridge socket were using temporary directory, but the good practice is to use XDG_RUNTIME_DIR instead.
This commit is contained in:
parent
1cf75f1126
commit
a338bef90d
2 changed files with 7 additions and 6 deletions
|
|
@ -38,6 +38,7 @@ xdg_config_dirs = [
|
|||
d for d in os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":") if d
|
||||
]
|
||||
xdg_data_home = Path(os.environ.get("XDG_DATA_HOME") or Path.home() / ".local/share")
|
||||
xdg_runtime_dir = Path(os.environ.get("XDG_RUNTIME_DIR") or f"/run/user/{os.getuid()}")
|
||||
|
||||
|
||||
class Const:
|
||||
|
|
@ -80,7 +81,7 @@ class Const:
|
|||
for p in CONFIG_PATHS:
|
||||
CONFIG_FILES.append(p / f"{APP_NAME_FILE}.toml")
|
||||
|
||||
TEMP_DIR = Path(tempfile.gettempdir(), f"{APP_NAME_FILE}_{logged_user}")
|
||||
RUNTIME_DIR = xdg_runtime_dir / APP_NAME_FILE
|
||||
|
||||
## Runtime ##
|
||||
PLUGIN_EXT = "py"
|
||||
|
|
|
|||
|
|
@ -167,10 +167,10 @@ class PbBridgeSettings(ConfigOptions):
|
|||
default=8789, description='TCP port to use when ``connection_type`` is "socket"'
|
||||
)
|
||||
socket_dir: DirectoryPathAuto = Field(
|
||||
default=C.TEMP_DIR,
|
||||
default=C.RUNTIME_DIR,
|
||||
description=(
|
||||
"Directory where the UNIX socket file will be created when using unix_socket"
|
||||
" connection type."
|
||||
" connection type. Default is the user's runtime directory."
|
||||
),
|
||||
)
|
||||
host: str = Field(
|
||||
|
|
@ -263,10 +263,10 @@ class CommonSettings(ConfigOptions):
|
|||
)
|
||||
log_fmt: str | None = Field(default=None, description="Log message format")
|
||||
pid_dir: DirectoryPathAuto = Field(
|
||||
default=C.TEMP_DIR,
|
||||
default=C.RUNTIME_DIR,
|
||||
description=(
|
||||
"Directory where PID files will be stored. Default is a subdirectory of the"
|
||||
" system's temporary directory."
|
||||
"Directory where PID files will be stored. Default is the user's runtime"
|
||||
" directory."
|
||||
),
|
||||
)
|
||||
xmpp_domain: str = Field(
|
||||
|
|
|
|||
Loading…
Reference in a new issue