mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-30 21:09:09 -07:00
created makedirs_safe function for use in cases of multiprocess
should fix #11126 and most race conditions
This commit is contained in:
parent
47be5b4166
commit
2590df6df1
5 changed files with 23 additions and 15 deletions
|
@ -44,6 +44,7 @@ from ansible import constants as C
|
|||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
||||
from ansible.plugins.connections import ConnectionBase
|
||||
from ansible.plugins import shell_loader
|
||||
from ansible.utils import makedirs_safe
|
||||
|
||||
class Connection(ConnectionBase):
|
||||
'''WinRM connections over HTTP/HTTPS.'''
|
||||
|
@ -213,8 +214,7 @@ class Connection(ConnectionBase):
|
|||
out_path = out_path.replace('\\', '/')
|
||||
self._display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
|
||||
buffer_size = 2**19 # 0.5MB chunks
|
||||
if not os.path.exists(os.path.dirname(out_path)):
|
||||
os.makedirs(os.path.dirname(out_path))
|
||||
makedirs_safe(os.path.dirname(out_path))
|
||||
out_file = None
|
||||
try:
|
||||
offset = 0
|
||||
|
@ -251,8 +251,7 @@ class Connection(ConnectionBase):
|
|||
else:
|
||||
data = base64.b64decode(result.std_out.strip())
|
||||
if data is None:
|
||||
if not os.path.exists(out_path):
|
||||
os.makedirs(out_path)
|
||||
makedirs_safe(out_path)
|
||||
break
|
||||
else:
|
||||
if not out_file:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue