Skip to content

Fix symlink handling in dir_contains_files - #5236

Open
Flamefire wants to merge 2 commits into
easybuilders:developfrom
Flamefire:dir-with-symlinked-folder
Open

Fix symlink handling in dir_contains_files#5236
Flamefire wants to merge 2 commits into
easybuilders:developfrom
Flamefire:dir-with-symlinked-folder

Conversation

@Flamefire

Copy link
Copy Markdown
Contributor

When we check a directory that is a symlink to a folder with files or contains such a symlink but no files itself then this function would return False even though there are files reachable through that path.

Return True in this case now.

Fix also the handling of broken symlinks: os.path.isfile(p) returns True if p is a file or a symlink pointing to a file.
os.walk yields symlinks always as files so without checking for isfile there we would have different results for a folder that contains a broken symlink.
Uniformly return False now

When we check a directory that is a symlink to a folder with files or
contains such a symlink but no files itself then this function would
return False even though there are files reachable through that path.

Return True in this case now.
…ursive paths

The non-recursive check used `isfile` which the recursive check is
missing and hence leads to different results for broken symlinks.
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.

1 participant