Skip to content

Commit a77468c

Browse files
authored
Merge pull request #740 from jbradberry/fix-ocp-precreated-dirs
Do not attempt to chmod the special pre-created dirs during unstreaming
2 parents ee8e927 + b9574e1 commit a77468c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ansible_runner/utils/streaming.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ def unstream_dir(stream, length, target_directory):
7171
# https://www.burgundywall.com/post/preserving-file-perms-with-python-zipfile-module
7272
for info in archive.infolist():
7373
out_path = os.path.join(target_directory, info.filename)
74-
74+
7575
perms = info.external_attr >> 16
7676
mode = stat.filemode(perms)
77-
77+
7878
is_symlink = mode[:1] == 'l'
79-
if is_symlink and os.path.exists(out_path):
80-
os.remove(out_path)
81-
79+
if os.path.exists(out_path):
80+
if is_symlink:
81+
os.remove(out_path)
82+
elif os.path.isdir(out_path):
83+
# Special case, the important dirs were pre-created so don't try to chmod them
84+
continue
85+
8286
archive.extract(info.filename, path=target_directory)
8387

8488
if is_symlink:

0 commit comments

Comments
 (0)