From a29687a6442dc26887c5777132511b2dc4d738f6 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 7 Nov 2024 22:25:13 -0600 Subject: [PATCH] fix _safe_stat() It needs to return the stat, and we need to continue if it returns None. --- deploy/bootstrap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deploy/bootstrap.py b/deploy/bootstrap.py index f52473c2a..6781d108b 100755 --- a/deploy/bootstrap.py +++ b/deploy/bootstrap.py @@ -1181,6 +1181,8 @@ def _update_permissions(options, directories): # noqa: C901 # os.walk() for directory in directories: dir_stat = _safe_stat(directory) + if dir_stat is None: + continue perm = dir_stat.st_mode & mask @@ -1220,6 +1222,8 @@ def _update_permissions(options, directories): # noqa: C901 directory = os.path.join(root, directory) dir_stat = _safe_stat(directory) + if dir_stat is None: + continue if dir_stat.st_uid != new_uid: # current user doesn't own this dir so let's move on @@ -1244,6 +1248,8 @@ def _update_permissions(options, directories): # noqa: C901 pass file_name = os.path.join(root, file_name) file_stat = _safe_stat(file_name) + if file_stat is None: + continue if file_stat.st_uid != new_uid: # current user doesn't own this file so let's move on @@ -1341,7 +1347,7 @@ def _safe_rmtree(path): @_ignore_file_errors def _safe_stat(path): - os.stat(path) + return os.stat(path) def _discover_machine(quiet=False):