Skip to content

operations.files.download: reconcile mode/user/group on existing files#1687

Open
wowi42 wants to merge 1 commit intopyinfra-dev:3.xfrom
KalvadTech:fix/files-download-reconcile-mode
Open

operations.files.download: reconcile mode/user/group on existing files#1687
wowi42 wants to merge 1 commit intopyinfra-dev:3.xfrom
KalvadTech:fix/files-download-reconcile-mode

Conversation

@wowi42
Copy link
Copy Markdown
Collaborator

@wowi42 wowi42 commented Apr 21, 2026

download() short-circuits to a noop whenever the destination exists (and cache_time / checksums don't say otherwise), so changing the mode, user or group argument had no effect unless you manually deleted the target first. Compare the requested mode/owner against the File fact and emit chmod/chown when they differ; only noop when the file and its metadata both match.

Widen the mode parameter's type to int | str | None to match files.file() and let ensure_mode_int() reassignment type-check cleanly. Closes #1200.

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)

download() short-circuits to a noop whenever the destination exists
(and cache_time / checksums don't say otherwise), so changing the mode,
user or group argument had no effect unless you manually deleted the
target first. Compare the requested mode/owner against the File fact
and emit chmod/chown when they differ; only noop when the file and its
metadata both match.

Widen the mode parameter's type to int | str | None to match
files.file() and let ensure_mode_int() reassignment type-check cleanly.
Closes pyinfra-dev#1200.
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.

files.download does not correct the file mode

1 participant