Repository navigation
Conversation
Fizzadar
left a comment
There was a problem hiding this comment.
One problem with recursive inline, otherwise this looks good!
| # Skip a symbolic mode (eg "g+w") that wouldn't change the directory | ||
| if isinstance(mode, str) and apply_symbolic_mode(info["mode"], mode) == info["mode"]: | ||
| mode = None |
There was a problem hiding this comment.
With recursive=True this skips the chmod when the top directory already matches, but children could still be wrong. Should we only skip when recursive is false? Also this block overlaps with #2117, so this needs a rebase now 🙏
There was a problem hiding this comment.
@Fizzadar nice catch, thanks!
It now only skips when recursive is false and there is a test for the recursive case. I also rebased
7ff5975 to
89ce7fc
Compare
wowi42
left a comment
There was a problem hiding this comment.
The helper's chmod behavior checks out, but one central branch is not tested.
| - testdir | ||
| kwargs: | ||
| mode: u+rwx,g+rwx,o+rwx | ||
| recursive: true |
There was a problem hiding this comment.
This fixture sets recursive: true, so it does not exercise the non-recursive changed-mode fallthrough. Please remove recursive: true and expect chmod u+rwx,g+rwx,o+rwx testdir without -R.
There was a problem hiding this comment.
Thanks, good catch. Dropped recursive: true so this fixture now covers the non-recursive changed-mode path (chmod without -R). The recursive case is still covered by edit_symbolic_mode_recursive.yaml.
Fixes #2084
What
files.directory(mode="u+rwx,g+rwx,o-rwx")ranchmodon every deploy, even when the directory already had that mode.Why
The directory's current mode is a number (
770), but a symbolic mode stays as text, so770 != "u+rwx,g+rwx,o-rwx"was always true.Changes
apply_symbolic_mode()inoperations/util/files.py. It works out the number a symbolic mode would give the current directory, e.g.770+"o+rwx"→777.files.directoryskipschmodwhen that number already matches. Otherwise it still sends the symbolic mode as-is, so nothing else changes.recursive=Trueit always runschmod -Rlike before, because files inside could still need it.chmodlike before: nou/g/o/a(e.g.+x, which depends on the umask),X/s/t, or a directory with setuid/setgid/sticky bits.recursive→ chmod, no match → chmod,+x→ chmod).Rebased on #2117.
I also compared
apply_symbolic_mode()against the realchmod(macOS) on 3000 random modes, and they all matched.3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)AI disclosure: I used Claude Code to write the code and tests, and I reviewed and understand all of it.