Skip to content

Commit

Permalink
Don't use .cache if HOME=/
Browse files Browse the repository at this point in the history
If the user's home directory is /, don't use .cache but use /var/cache
instead.
  • Loading branch information
DaanDeMeyer committed Jul 29, 2024
1 parent b24f7fc commit 59b325f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mkosi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def is_regular_user(cls) -> bool:
def cache_dir(cls) -> Path:
if (env := os.getenv("XDG_CACHE_HOME")) or (env := os.getenv("CACHE_DIRECTORY")):
cache = Path(env)
elif cls.is_regular_user() and (Path.cwd().is_relative_to(INVOKING_USER.home()) or not cls.invoked_as_root):
elif (
cls.is_regular_user() and
INVOKING_USER.home() != Path("/") and
(Path.cwd().is_relative_to(INVOKING_USER.home()) or not cls.invoked_as_root)
):
cache = INVOKING_USER.home() / ".cache"
else:
cache = Path("/var/cache")
Expand Down

0 comments on commit 59b325f

Please sign in to comment.