Skip to content

fix: honor ensure_exists for XDG media directories - #559

Closed
ekanshul wants to merge 1 commit into
tox-dev:mainfrom
ekanshul:fix/ensure-exists-xdg-media-dirs
Closed

ekanshul wants to merge 1 commit into
tox-dev:mainfrom
ekanshul:fix/ensure-exists-xdg-media-dirs

Conversation

@ekanshul

@ekanshul ekanshul commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #558.

Unix(ensure_exists=True).user_documents_path returned $XDG_DOCUMENTS_DIR without creating it or its parents, while user_data_path created as documented.

XDGMixin (and the Unix user-dirs.dirs fallback) returned media paths directly and never called _optionally_create_directory. The same gap applied to downloads, pictures, videos, music, desktop, projects, public share, and templates.

This routes those paths through _optionally_create_directory so ensure_exists=True creates the directory and parents, and ensure_exists=False still leaves them alone.

Testing

  • Added Unix coverage for env-var media dirs (create / do not create) and for a user-dirs.dirs path.
  • Added a macOS env-var case, since MacOS uses the same mixin.
  • pytest tests (plus the appdirs comparison file): 1380 passed, skipped tests unchanged.

Media dirs from XDG_*_DIR and user-dirs.dirs skipped
_optionally_create_directory, so ensure_exists=True did
not create them or their parents.

Fixes tox-dev#558
@gaborbernat

Copy link
Copy Markdown
Member

Superseded by #560, which keeps your commit and adds one on top. Maintainer edits were disabled on this branch, so I could not push here. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unix.user_documents_dir ignores ensure_exists=True for XDG_DOCUMENTS_DIR

2 participants