@@ -93,23 +93,21 @@ def _handle_non_dir_str(path: str, user_uid: int):
9393 return None
9494
9595
96- def handle_non_dir (var , user_uid , inputdata_root ):
96+ def handle_non_dir (var , user_uid ):
9797 """
9898 Check if a non-directory is owned by the user and should be processed. Passes var to a
9999 helper function depending on its type.
100100
101101 Args:
102102 var (os.DirEntry or str): A directory entry from os.scandir(), or a string path.
103103 user_uid (int): The UID of the user whose files to find.
104- inputdata_root (str): The root of the directory tree containing CESM input data.
105104
106105 Returns:
107106 str or None: The absolute path to the file if it's owned by the user
108107 and is a regular file (not a symlink), otherwise None.
109108
110109 Raises:
111110 TypeError: If var is not a DirEntry-like object.
112- ValueError: If the file path is not under inputdata_root.
113111 """
114112
115113 # Handle a variable of type str.
@@ -130,12 +128,6 @@ def handle_non_dir(var, user_uid, inputdata_root):
130128 f"Unsure how to handle non-directory variable of type { type (var )} "
131129 )
132130
133- # Check that resulting path is a child of inputdata_root
134- if file_path is not None and not Path (file_path ).is_relative_to (inputdata_root ):
135- raise ValueError (
136- f"'{ file_path } ' must be equivalent to or under '{ inputdata_root } "
137- )
138-
139131 return file_path
140132
141133
@@ -169,7 +161,7 @@ def find_owned_files_scandir(item, user_uid, inputdata_root=DEFAULT_SOURCE_ROOT)
169161
170162 # Things other than directories are handled separately
171163 elif (
172- entry_path := handle_non_dir (entry , user_uid , inputdata_root )
164+ entry_path := handle_non_dir (entry , user_uid )
173165 ) is not None :
174166 yield entry_path
175167
@@ -178,7 +170,7 @@ def find_owned_files_scandir(item, user_uid, inputdata_root=DEFAULT_SOURCE_ROOT)
178170 continue
179171
180172 except NotADirectoryError :
181- if (file_path := handle_non_dir (item , user_uid , inputdata_root )) is not None :
173+ if (file_path := handle_non_dir (item , user_uid )) is not None :
182174 yield file_path
183175
184176 except (OSError , PermissionError ) as e :
0 commit comments