From 6b3d670d9c097feba52a2cba691bdd98953630a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Wed, 18 Oct 2023 11:21:42 +0200 Subject: [PATCH] fix: change back to old log dir after breaking change in platformdirs, pinned platformdirs --- aw_core/dirs.py | 11 +++++++++-- poetry.lock | 2 +- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/aw_core/dirs.py b/aw_core/dirs.py index 7cbf84d..a700d80 100644 --- a/aw_core/dirs.py +++ b/aw_core/dirs.py @@ -1,6 +1,7 @@ import os +import sys from functools import wraps -from typing import Optional, Callable +from typing import Callable, Optional import platformdirs @@ -42,5 +43,11 @@ def get_config_dir(module_name: Optional[str] = None) -> str: @_ensure_returned_path_exists def get_log_dir(module_name: Optional[str] = None) -> str: # pragma: no cover - log_dir = platformdirs.user_log_dir("activitywatch") + # on Linux/Unix, platformdirs changed to using XDG_STATE_HOME instead of XDG_DATA_HOME for log_dir in v2.6 + # we want to keep using XDG_DATA_HOME for backwards compatibility + # https://github.com/ActivityWatch/aw-core/pull/122#issuecomment-1768020335 + if sys.platform.startswith("linux"): + log_dir = platformdirs.user_data_path("activitywatch") / "log" + else: + log_dir = platformdirs.user_log_dir("activitywatch") return os.path.join(log_dir, module_name) if module_name else log_dir diff --git a/poetry.lock b/poetry.lock index 7671137..d2307e9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -933,4 +933,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "e8bcbf03b02ffe6321aec50f54d1e27a5e530b85f86c7f505594c9faccd50eee" +content-hash = "ec99e0e9832461084031d345c46368c3b39a0e045523e2dc15a863fd29f384d3" diff --git a/pyproject.toml b/pyproject.toml index 8b35e88..192c90d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ aw-cli = "aw_cli.__main__:main" python = "^3.8" jsonschema = "^4.3" peewee = "3.*" -platformdirs = "^3.8.0" +platformdirs = "3.10" # pinned due to sometimes breaking changes in minor versions: https://github.com/ActivityWatch/aw-core/pull/122#issuecomment-1768020335 iso8601 = "^1.0.2" rfc3339-validator = "^0.1.4" # needed for the date-type format in jsonschema strict-rfc3339 = "^0.7"