From 5259c3021328d19cb84ecf334130e9864863ef56 Mon Sep 17 00:00:00 2001 From: JiaSeng-v Date: Tue, 6 Oct 2026 13:55:23 +0800 Subject: [PATCH 1/2] Fix Issues 32147: Add condition checking to avoid infinite loop --- .../azure/cli/command_modules/storage/operations/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/storage/operations/file.py b/src/azure-cli/azure/cli/command_modules/storage/operations/file.py index f664cfd0ec2..b2c2471079d 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/operations/file.py +++ b/src/azure-cli/azure/cli/command_modules/storage/operations/file.py @@ -512,7 +512,7 @@ def _make_directory_in_files_share(file_service, directory_path, existing_dirs=N parents = [directory_path] p = os.path.dirname(directory_path) - while p: + while p and p != parents[-1]: parents.append(p) p = os.path.dirname(p) From 53548ca119d26402f1d705d141f90f3e1e160939 Mon Sep 17 00:00:00 2001 From: JiaSeng-v Date: Tue, 6 Oct 2026 14:09:55 +0800 Subject: [PATCH 2/2] stop directory walk before appending share root --- .../azure/cli/command_modules/storage/operations/file.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/storage/operations/file.py b/src/azure-cli/azure/cli/command_modules/storage/operations/file.py index b2c2471079d..c31c3f8e249 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/operations/file.py +++ b/src/azure-cli/azure/cli/command_modules/storage/operations/file.py @@ -512,7 +512,8 @@ def _make_directory_in_files_share(file_service, directory_path, existing_dirs=N parents = [directory_path] p = os.path.dirname(directory_path) - while p and p != parents[-1]: + # Stop once p reaches the root (dirname(p) == p), so the share root is never queued for creation + while p and p != os.path.dirname(p): parents.append(p) p = os.path.dirname(p)