mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-10 06:35:27 +01:00
refactor(acl): improve execution speed
This commit is contained in:
parent
392fd0deaa
commit
9ec1d668b4
1 changed files with 5 additions and 11 deletions
|
|
@ -243,23 +243,17 @@ def acl_changed(module, cmd, entry, use_nfsv4_acls=False):
|
|||
cmd.insert(1, '--test')
|
||||
lines = run_acl(module, cmd)
|
||||
counter = 0
|
||||
lines_checked = 0
|
||||
lines_unchanged = 0
|
||||
for line in lines:
|
||||
lines_checked += 1
|
||||
if line.endswith('*,*') and not use_nfsv4_acls:
|
||||
lines_unchanged += 1
|
||||
if not use_nfsv4_acls and not line.endswith('*,*'):
|
||||
return True
|
||||
# if use_nfsv4_acls and entry is listed
|
||||
if use_nfsv4_acls and entry == line:
|
||||
counter += 1
|
||||
|
||||
if lines_unchanged == lines_checked:
|
||||
return False
|
||||
|
||||
# The current 'nfs4_setfacl --test' lists a new entry,
|
||||
# which will be added at the top of list, followed by the existing entries.
|
||||
# So if the entry has already been registered, the entry should be find twice.
|
||||
if counter == 2:
|
||||
# which will be added at the top of the list, followed by the existing entries.
|
||||
# So if the entry has already been registered, the entry should be found twice.
|
||||
if not use_nfsv4_acls or counter == 2:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue