diff --git a/CHANGES.rst b/CHANGES.rst index b2c67f5..710ddad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ platformdirs Changelog ====================== +platformdirs 2.6.0 (2022-12-06) +------------------------------- +- **BREAKING** Correct the log directory on Linux/Unix from + XDG_CACHE_HOME to XDG_STATE_HOME per the XDG spec + platformdirs 2.5.4 (2022-11-12) ------------------------------- - Fix licesing metadata diff --git a/src/platformdirs/unix.py b/src/platformdirs/unix.py index 2fbd4d4..9aca5a0 100644 --- a/src/platformdirs/unix.py +++ b/src/platformdirs/unix.py @@ -107,9 +107,9 @@ def user_state_dir(self) -> str: @property def user_log_dir(self) -> str: """ - :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it + :return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it """ - path = self.user_cache_dir + path = self.user_state_dir if self.opinion: path = os.path.join(path, "log") return path diff --git a/tests/test_comp_with_appdirs.py b/tests/test_comp_with_appdirs.py index c4b4c65..2027a75 100644 --- a/tests/test_comp_with_appdirs.py +++ b/tests/test_comp_with_appdirs.py @@ -62,6 +62,12 @@ def test_compatibility(params: dict[str, Any], func: str) -> None: } if func in msg: # pragma: no cover pytest.skip(f"`appdirs.{func}` {msg[func]} on macOS") # pragma: no cover + if sys.platform == "linux": + msg = { # pragma: no cover + "user_log_dir": "Uses XDG_STATE_DIR instead of appdirs.user_data_dir per the XDG spec", + } + if func in msg: # pragma: no cover + pytest.skip(f"`appdirs.{func}` {msg[func]} on Linux") # pragma: no cover new = getattr(platformdirs, func)(*params) old = getattr(appdirs, func)(*params) diff --git a/tests/test_unix.py b/tests/test_unix.py index 272c28e..f5d4661 100644 --- a/tests/test_unix.py +++ b/tests/test_unix.py @@ -59,7 +59,7 @@ def _func_to_path(func: str) -> XDGVariable | None: "site_config_dir": XDGVariable("XDG_CONFIG_DIRS", "/etc/xdg"), "user_cache_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"), "user_state_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"), - "user_log_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"), + "user_log_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"), "user_runtime_dir": XDGVariable("XDG_RUNTIME_DIR", "/run/user/1234"), } return mapping.get(func)