Remove NOP pass statements from file.check_perms

While refactoring the `mode` update section the `else` statements were
removed which rendered the `if ...: pass` a NOP. The PR negates the
`if is_link and not follow_symlinks` so we only continue to change the
mode for non-links and link targets if `follow_symlinks == True`.
This commit is contained in:
Nick Rhodes 2022-10-01 21:03:59 +01:00 committed by Gareth J. Greenaway
parent be05e799fe
commit 405d48bd28

View file

@ -5171,14 +5171,12 @@ def check_perms(
if mode is not None:
# File is a symlink, ignore the mode setting
# if follow_symlinks is False
if is_link and not follow_symlinks:
pass
if __opts__["test"] is True:
ret["changes"]["mode"] = mode
else:
if not mode == cur["mode"]:
set_mode(name, mode)
if not (is_link and not follow_symlinks):
if __opts__["test"] is True:
ret["changes"]["mode"] = mode
else:
if not mode == cur["mode"]:
set_mode(name, mode)
# verify user/group/mode changes
post = stats(name, follow_symlinks=follow_symlinks)
@ -5217,22 +5215,18 @@ def check_perms(
if mode is not None:
# File is a symlink, ignore the mode setting
# if follow_symlinks is False
if is_link and not follow_symlinks:
pass
if not mode == post["mode"]:
ret["result"] = False
ret["comment"].append("Failed to change mode to {}".format(mode))
else:
ret["changes"]["mode"] = mode
if not (is_link and not follow_symlinks):
if not mode == post["mode"]:
ret["result"] = False
ret["comment"].append("Failed to change mode to {}".format(mode))
else:
ret["changes"]["mode"] = mode
# Modify attributes of file if needed
if attrs is not None and not is_dir:
# File is a symlink, ignore the mode setting
# if follow_symlinks is False
if is_link and not follow_symlinks:
pass
else:
if not (is_link and not follow_symlinks):
diff_attrs = _cmp_attrs(name, attrs)
if diff_attrs and any(attr for attr in diff_attrs):
changes = {