@@ -97,7 +97,7 @@ def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystem
9797 Statistics tracking object for the total file count and size.
9898
9999 """
100- if limit_exceeded (stats , depth = node .depth ):
100+ if limit_exceeded (stats , depth = node .depth , query = query ):
101101 return
102102
103103 for sub_path in node .path .iterdir ():
@@ -113,7 +113,7 @@ def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystem
113113 if sub_path .stat ().st_size > query .max_file_size :
114114 print (f"Skipping file { sub_path } : would exceed max file size limit" )
115115 continue
116- _process_file (path = sub_path , parent_node = node , stats = stats , local_path = query .local_path )
116+ _process_file (path = sub_path , parent_node = node , stats = stats , local_path = query .local_path , query = query )
117117 elif sub_path .is_dir ():
118118 child_directory_node = FileSystemNode (
119119 name = sub_path .name ,
@@ -167,7 +167,7 @@ def _process_symlink(path: Path, parent_node: FileSystemNode, stats: FileSystemS
167167 parent_node .file_count += 1
168168
169169
170- def _process_file (path : Path , parent_node : FileSystemNode , stats : FileSystemStats , local_path : Path ) -> None :
170+ def _process_file (path : Path , parent_node : FileSystemNode , stats : FileSystemStats , local_path : Path , query : IngestionQuery ) -> None :
171171 """Process a file in the file system.
172172
173173 This function checks the file's size, increments the statistics, and reads its content.
@@ -183,14 +183,16 @@ def _process_file(path: Path, parent_node: FileSystemNode, stats: FileSystemStat
183183 Statistics tracking object for the total file count and size.
184184 local_path : Path
185185 The base path of the repository or directory being processed.
186+ query : IngestionQuery
187+ The query object containing the limit configurations.
186188
187189 """
188- if stats .total_files + 1 > MAX_FILES :
189- print (f"Maximum file limit ({ MAX_FILES } ) reached" )
190+ if stats .total_files + 1 > query . max_files :
191+ print (f"Maximum file limit ({ query . max_files } ) reached" )
190192 return
191193
192194 file_size = path .stat ().st_size
193- if stats .total_size + file_size > MAX_TOTAL_SIZE_BYTES :
195+ if stats .total_size + file_size > query . max_total_size_bytes :
194196 print (f"Skipping file { path } : would exceed total size limit" )
195197 return
196198
@@ -212,7 +214,7 @@ def _process_file(path: Path, parent_node: FileSystemNode, stats: FileSystemStat
212214 parent_node .file_count += 1
213215
214216
215- def limit_exceeded (stats : FileSystemStats , depth : int ) -> bool :
217+ def limit_exceeded (stats : FileSystemStats , depth : int , query : IngestionQuery ) -> bool :
216218 """Check if any of the traversal limits have been exceeded.
217219
218220 This function checks if the current traversal has exceeded any of the configured limits:
@@ -224,23 +226,25 @@ def limit_exceeded(stats: FileSystemStats, depth: int) -> bool:
224226 Statistics tracking object for the total file count and size.
225227 depth : int
226228 The current depth of directory traversal.
229+ query : IngestionQuery
230+ The query object containing the limit configurations.
227231
228232 Returns
229233 -------
230234 bool
231235 ``True`` if any limit has been exceeded, ``False`` otherwise.
232236
233237 """
234- if depth > MAX_DIRECTORY_DEPTH :
235- print (f"Maximum depth limit ({ MAX_DIRECTORY_DEPTH } ) reached" )
238+ if depth > query . max_directory_depth :
239+ print (f"Maximum depth limit ({ query . max_directory_depth } ) reached" )
236240 return True
237241
238- if stats .total_files >= MAX_FILES :
239- print (f"Maximum file limit ({ MAX_FILES } ) reached" )
242+ if stats .total_files >= query . max_files :
243+ print (f"Maximum file limit ({ query . max_files } ) reached" )
240244 return True # TODO: end recursion
241245
242- if stats .total_size >= MAX_TOTAL_SIZE_BYTES :
243- print (f"Maxumum total size limit ({ MAX_TOTAL_SIZE_BYTES / 1024 / 1024 :.1f} MB) reached" )
246+ if stats .total_size >= query . max_total_size_bytes :
247+ print (f"Maxumum total size limit ({ query . max_total_size_bytes / 1024 / 1024 :.1f} MB) reached" )
244248 return True # TODO: end recursion
245249
246250 return False
0 commit comments