From f4cff45d46d5cab0ef38138e38a6ece23c6f7b25 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Fri, 25 Nov 2022 23:29:30 -0800 Subject: [PATCH 1/4] Change user_log_dir to point to user_state_dir on Linux per the XDG spec Fixes #106 --- src/platformdirs/unix.py | 4 ++-- tests/test_unix.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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_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) From e8d3a5a523a00e9bd5ca00c26b54695d56e815fa Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 29 Nov 2022 23:38:52 -0800 Subject: [PATCH 2/4] Add exception in appdirs compatibility test --- tests/test_comp_with_appdirs.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) From 71c926de32f81f3e19d1a50b8f9d97c4a9ec7068 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Mon, 5 Dec 2022 23:56:07 -0800 Subject: [PATCH 3/4] Update CHANGES.rst --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index b2c67f5..95cf81e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ platformdirs Changelog ====================== +- **BREAKING** Correct the log directory on Linux/Unix + platformdirs 2.5.4 (2022-11-12) ------------------------------- - Fix licesing metadata From 3668b7e6750acfefdf4637e5a5dfc8736a345f9c Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 6 Dec 2022 16:12:33 -0800 Subject: [PATCH 4/4] State what the new path is in the changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Listed under version 2.6.0 per Bernát Gábor --- CHANGES.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 95cf81e..710ddad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,10 @@ platformdirs Changelog ====================== -- **BREAKING** Correct the log directory on Linux/Unix +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) -------------------------------