summaryrefslogtreecommitdiff
path: root/lib/ansible/collections
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2020-12-14 19:30:13 -0500
committerGitHub <noreply@github.com>2020-12-14 19:30:13 -0500
commitd22804c4fbb85010c4589836cd59284c2cf11f9e (patch)
tree7fe05fa7eeffb347184bfe0b03e029f094bcee54 /lib/ansible/collections
parent5157a92139b04fef32d38498815084a27adcd758 (diff)
downloadansible-d22804c4fbb85010c4589836cd59284c2cf11f9e.tar.gz
saner path dir management (#72648)
* saner path dir management fixes #72628 ensure we always store paths w/o a_c Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
Diffstat (limited to 'lib/ansible/collections')
-rw-r--r--lib/ansible/collections/list.py47
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/ansible/collections/list.py b/lib/ansible/collections/list.py
index a1d9901706..c6af77a364 100644
--- a/lib/ansible/collections/list.py
+++ b/lib/ansible/collections/list.py
@@ -69,33 +69,34 @@ def list_collection_dirs(search_paths=None, coll_filter=None):
collections = defaultdict(dict)
for path in list_valid_collection_paths(search_paths):
- b_path = to_bytes(path)
- if os.path.isdir(b_path):
- b_coll_root = to_bytes(os.path.join(path, 'ansible_collections'))
+ if os.path.basename(path) != 'ansible_collections':
+ path = os.path.join(path, 'ansible_collections')
+
+ b_coll_root = to_bytes(path, errors='surrogate_or_strict')
- if os.path.exists(b_coll_root) and os.path.isdir(b_coll_root):
+ if os.path.exists(b_coll_root) and os.path.isdir(b_coll_root):
- if namespace is None:
- namespaces = os.listdir(b_coll_root)
- else:
- namespaces = [namespace]
+ if namespace is None:
+ namespaces = os.listdir(b_coll_root)
+ else:
+ namespaces = [namespace]
- for ns in namespaces:
- b_namespace_dir = os.path.join(b_coll_root, to_bytes(ns))
+ for ns in namespaces:
+ b_namespace_dir = os.path.join(b_coll_root, to_bytes(ns))
- if os.path.isdir(b_namespace_dir):
+ if os.path.isdir(b_namespace_dir):
- if collection is None:
- colls = os.listdir(b_namespace_dir)
- else:
- colls = [collection]
+ if collection is None:
+ colls = os.listdir(b_namespace_dir)
+ else:
+ colls = [collection]
- for mycoll in colls:
+ for mycoll in colls:
- # skip dupe collections as they will be masked in execution
- if mycoll not in collections[ns]:
- b_coll = to_bytes(mycoll)
- b_coll_dir = os.path.join(b_namespace_dir, b_coll)
- if is_collection_path(b_coll_dir):
- collections[ns][mycoll] = b_coll_dir
- yield b_coll_dir
+ # skip dupe collections as they will be masked in execution
+ if mycoll not in collections[ns]:
+ b_coll = to_bytes(mycoll)
+ b_coll_dir = os.path.join(b_namespace_dir, b_coll)
+ if is_collection_path(b_coll_dir):
+ collections[ns][mycoll] = b_coll_dir
+ yield b_coll_dir