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

files.download does not correct the file mode #1200

Open
RichardKraus opened this issue Sep 7, 2024 · 0 comments
Open

files.download does not correct the file mode #1200

RichardKraus opened this issue Sep 7, 2024 · 0 comments
Labels
bug Label for all kind of bugs. operations Issues with operations.

Comments

@RichardKraus
Copy link

Describe the bug

files.download does not correct the mode of already existing files, even if they differ from the specified ones. The outcome of the operation is therefore dependent on the state of the machine before the operation, and may differ from the state requested in the operation. I would consider this a bug.

To Reproduce

$ pyinfra -y @local files.download https://get.k3s.io ./here mode=u=rw
[...]
$ ll here
-rw-r--r-- 1 rickra rickra 36K Sep  7 08:00 here
$ pyinfra -y @local files.download https://get.k3s.io ./here mode=777
[...]
$ ll here  # here, the permissions should be adjusted, but arent
-rw-r--r-- 1 rickra rickra 36K Sep  7 08:00 here
$ rm here
$ pyinfra -y @local files.download https://get.k3s.io ./here mode=777
[...]
$ ll here
-rwxrwxrwx 1 rickra rickra 36K Sep  7 08:04 here

This is because files.download only checks if any file exists or the hashes differ from optionally supplied ones. There should be an additional mode check.

Expected behavior

If the file mode differs, the file mode should at least be adjusted to match the requested mode.
I would personally argue that the file should be redownloaded when the mode argument is changed, since I would translate the operation name "download" as "download if the state does not match the expected" (as in file does not exist, file too old, ...).

@Fizzadar Fizzadar added bug Label for all kind of bugs. operations Issues with operations. labels Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Label for all kind of bugs. operations Issues with operations.
Projects
None yet
Development

No branches or pull requests

2 participants