Skip to content

🐛 fix(api): raise when a media dir is a file - #672

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
rupayon123:fix/media-file-collision-20261028
Oct 28, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
rupayon123:fix/media-file-collision-20261028

Conversation

@rupayon123

@rupayon123 rupayon123 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

With ensure_exists, a media directory the user configured through an XDG_*_DIR variable or user-dirs.dirs could point at a regular file, and platformdirs returned the file's path. _optionally_create_media_directory suppressed every FileExistsError so that dangling links to unmounted storage keep working (#561), and that also hid file collisions.

It now re-raises FileExistsError unless the path is a symlink whose target is missing. A regular file or a symlink to one raises; dangling links and symlink loops are returned unchanged, and symlinks to directories never raise. This covers the XDG variables, user-dirs.dirs and the module-level media functions such as user_documents_path.

Move the file and file-symlink setup into a media_file fixture so each
test checks only that ensure_exists raises FileExistsError, and replace
the branching symlink controls test with parameters. Move the
module-level function test next to the other media function tests in
test_unix.py and skip it on Windows, which reads Known Folders.

Name the changelog fragment after the PR and fold the new rule into the
ensure_exists paragraph of parameters.rst.
@gaborbernat gaborbernat changed the title Report configured media paths that collide with regular files 🐛 fix(api): raise when a media dir is a file Oct 28, 2026
@gaborbernat gaborbernat added the bug Something isn't working label Oct 28, 2026
@gaborbernat
gaborbernat enabled auto-merge (squash) October 28, 2026 18:20

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat
gaborbernat merged commit 3a5e7d0 into tox-dev:main Oct 28, 2026
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants