@@ -130,7 +130,7 @@ impl StageFilesInfo {
130130 mut files : & [ String ] ,
131131 ) -> Result < Vec < StageFileInfo > > {
132132 if let Some ( m) = max_files {
133- files = & files[ ..m]
133+ files = & files[ ..m. min ( files . len ( ) ) ]
134134 }
135135 let file_infos = self . stat_concurrent ( operator, thread_num, files) . await ?;
136136 let mut res = Vec :: with_capacity ( file_infos. len ( ) ) ;
@@ -207,39 +207,6 @@ impl StageFilesInfo {
207207 Ok ( files. pop ( ) )
208208 }
209209
210- pub fn blocking_list (
211- & self ,
212- operator : & Operator ,
213- max_files : Option < usize > ,
214- ) -> Result < Vec < StageFileInfo > > {
215- let max_files = max_files. unwrap_or ( usize:: MAX ) ;
216- if let Some ( files) = & self . files {
217- let mut res = Vec :: new ( ) ;
218- for file in files {
219- let full_path = Path :: new ( & self . path )
220- . join ( file)
221- . to_string_lossy ( )
222- . trim_start_matches ( '/' )
223- . to_string ( ) ;
224- let meta = operator. blocking ( ) . stat ( & full_path) ?;
225- if meta. mode ( ) . is_file ( ) {
226- res. push ( StageFileInfo :: new ( full_path, & meta) )
227- } else {
228- return Err ( ErrorCode :: BadArguments ( format ! (
229- "{full_path} is not a file"
230- ) ) ) ;
231- }
232- if res. len ( ) == max_files {
233- return Ok ( res) ;
234- }
235- }
236- Ok ( res)
237- } else {
238- let pattern = self . get_pattern ( ) ?;
239- blocking_list_files_with_pattern ( operator, & self . path , pattern, max_files)
240- }
241- }
242-
243210 #[ async_backtrace:: framed]
244211 pub async fn list_files_with_pattern (
245212 operator : & Operator ,
@@ -374,52 +341,6 @@ fn check_file(path: &str, mode: EntryMode, pattern: &Option<Regex>) -> bool {
374341 }
375342}
376343
377- fn blocking_list_files_with_pattern (
378- operator : & Operator ,
379- path : & str ,
380- pattern : Option < Regex > ,
381- max_files : usize ,
382- ) -> Result < Vec < StageFileInfo > > {
383- if path == STDIN_FD {
384- return Ok ( vec ! [ stdin_stage_info( ) ] ) ;
385- }
386- let operator = operator. blocking ( ) ;
387- let mut files = Vec :: new ( ) ;
388- let prefix_meta = operator. stat ( path) ;
389- match prefix_meta {
390- Ok ( meta) if meta. is_file ( ) => {
391- files. push ( StageFileInfo :: new ( path. to_string ( ) , & meta) ) ;
392- }
393- Err ( e) if e. kind ( ) != opendal:: ErrorKind :: NotFound => {
394- return Err ( e. into ( ) ) ;
395- }
396- _ => { }
397- } ;
398- let prefix_len = if path == "/" { 0 } else { path. len ( ) } ;
399- let list = operator. lister_with ( path) . recursive ( true ) . call ( ) ?;
400- if files. len ( ) == max_files {
401- return Ok ( files) ;
402- }
403- for obj in list {
404- let obj = obj?;
405- let ( path, mut meta) = obj. into_parts ( ) ;
406- if check_file ( & path[ prefix_len..] , meta. mode ( ) , & pattern) {
407- if meta. etag ( ) . is_none ( ) {
408- meta = match operator. stat ( & path) {
409- Ok ( meta) => meta,
410- Err ( err) => return Err ( ErrorCode :: from ( err) ) ,
411- }
412- }
413-
414- files. push ( StageFileInfo :: new ( path, & meta) ) ;
415- if files. len ( ) == max_files {
416- return Ok ( files) ;
417- }
418- }
419- }
420- Ok ( files)
421- }
422-
423344pub const STDIN_FD : & str = "/dev/fd/0" ;
424345
425346fn stdin_stage_info ( ) -> StageFileInfo {
0 commit comments