This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 4faae4bd7b7 Adding from_path.exists() check in a couple of conditions 
(#46255)
4faae4bd7b7 is described below

commit 4faae4bd7b77b98540ce00b37020bc5d02ffb79a
Author: Kunal Bhattacharya <[email protected]>
AuthorDate: Thu Jan 30 05:36:16 2025 +0530

    Adding from_path.exists() check in a couple of conditions (#46255)
---
 dev/moving_providers/move_providers.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dev/moving_providers/move_providers.py 
b/dev/moving_providers/move_providers.py
index ffecbb8ed5a..b1d7519eb6d 100755
--- a/dev/moving_providers/move_providers.py
+++ b/dev/moving_providers/move_providers.py
@@ -109,7 +109,11 @@ def _do_stuff(
                 console.print(Syntax(updated_str, syntax, theme="ansi_dark"))
         elif not from_content and not updated_content and from_path and 
to_path and delete_from:
             console.print(f"\n[yellow]Moving[/] {from_path} -> {to_path}\n")
-            if remove_empty_parent_dir and len([path for path in 
from_path.parent.iterdir()]) == 1:
+            if (
+                remove_empty_parent_dir
+                and from_path.exists()
+                and len([path for path in from_path.parent.iterdir()]) == 1
+            ):
                 console.print(f"\n[yellow]Removing also empty parent dir 
{from_path.parent}\n")
         elif not from_content and not updated_content and from_path and 
to_path and not delete_from:
             console.print(f"\n[yellow]Copying[/] {from_path} -> {to_path}\n")
@@ -127,7 +131,8 @@ def _do_stuff(
                 to_path.parent.mkdir(parents=True, exist_ok=True)
                 if from_path.is_dir() and to_path.exists():
                     shutil.rmtree(to_path)
-                shutil.move(from_path, to_path)
+                if from_path.exists():
+                    shutil.move(from_path, to_path)
                 console.print(f"\n[yellow]Moved {from_path} -> {to_path}\n")
                 if remove_empty_parent_dir and len([path for path in 
from_path.parent.iterdir()]) == 0:
                     console.print(f"\n[yellow]Removed also empty parent dir 
{from_path.parent}\n")

Reply via email to