Add mode to _makedirs call in file.copy

This commit is contained in:
Ch3LL 2018-07-09 15:47:37 -04:00
parent 2cbcb4fd26
commit d16a790775
No known key found for this signature in database
GPG key ID: 132B55A7C13EFA73
2 changed files with 8 additions and 4 deletions

View file

@ -5663,7 +5663,7 @@ def copy(
if not os.path.isdir(dname):
if makedirs:
try:
_makedirs(name=name, user=user, group=group)
_makedirs(name=name, user=user, group=group, dir_mode=mode)
except CommandExecutionError as exc:
return _error(ret, 'Drive {0} is not mapped'.format(exc.message))
else:

View file

@ -2493,12 +2493,16 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
dest = os.path.join(TMP, 'dir1', 'dir2', 'copied_file.txt')
user = 'salt'
mode = '0644'
self.run_function('user.add', [user])
ret = self.run_state('file.copy', name=dest, source=source, user=user, makedirs=True)
ret = self.run_state('file.copy', name=dest, source=source, user=user,
makedirs=True, mode=mode)
file_checks = [dest, os.path.join(TMP, 'dir1'), os.path.join(TMP, 'dir1', 'dir2')]
for check in file_checks:
ret = self.run_function('file.get_user', [check])
assert ret == user
user_check = self.run_function('file.get_user', [check])
mode_check = self.run_function('file.get_mode', [check])
assert user_check == user
assert salt.utils.normalize_mode(mode_check) == mode
def test_contents_pillar_with_pillar_list(self):
'''