Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copy_file with a folder as the target #4609

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Aug 12, 2024

This use case comes up with e.g. --copy-ec /tmp.

The existing code will see that /tmp exists and has a different UID and hence will use shutil.copyfile which expects the target to not be a folder. It hence fails with "[Errno 21] Is a directory"

Check for that case and make sure the target is always a file, not a directory.

This use case comes up with e.g. `--copy-ec /tmp`.
The existing code will see that `/tmp` exists and has a different UID
and hence will use `shutil.copy_file` which expects the target to not be
a folder. It hence fails with "[Errno 21] Is a directory"
Use `shutil.copy` as was likely intended anyway.
`shutil.copy` tries to change permissions which isn't allowed in the case where it is used.
As we already made sure the target is a file we can use `shutil.copyfile`
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel boegel merged commit f28f0b1 into easybuilders:develop Aug 13, 2024
37 checks passed
@Flamefire Flamefire deleted the fix-copy branch August 14, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants