mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 01:12:33 -05:00
Prefer home directory even for system users if it exists (#5022)
This commit is contained in:
@@ -36,13 +36,21 @@ basic_config_default: Dict[str, Any] = {
|
||||
"CORE_PATH_APPEND": "core",
|
||||
}
|
||||
|
||||
config_dir = None
|
||||
appdir = appdirs.AppDirs("Red-DiscordBot")
|
||||
if sys.platform == "linux":
|
||||
if 0 < os.getuid() < 1000: # pylint: disable=no-member
|
||||
config_dir = Path(appdir.user_config_dir)
|
||||
_system_user = sys.platform == "linux" and 0 < os.getuid() < 1000
|
||||
if _system_user:
|
||||
if Path.home().exists():
|
||||
# We don't want to break someone just because they created home dir
|
||||
# but were already using the site_data_dir.
|
||||
#
|
||||
# But otherwise, we do want Red to use user_config_dir if home dir exists.
|
||||
_maybe_config_file = Path(appdir.site_data_dir) / "config.json"
|
||||
if _maybe_config_file.exists():
|
||||
config_dir = _maybe_config_file.parent
|
||||
else:
|
||||
config_dir = Path(appdir.site_data_dir)
|
||||
if not config_dir:
|
||||
config_dir = Path(appdir.user_config_dir)
|
||||
|
||||
config_file = config_dir / "config.json"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user