@@ -166,11 +166,7 @@ impl Stat {
166166
167167 /// Create a Stat using safe traversal methods with `DirFd` for the root directory
168168 #[ cfg( target_os = "linux" ) ]
169- fn new_from_dirfd (
170- dir_fd : & DirFd ,
171- full_path : & Path ,
172- _options : & TraversalOptions ,
173- ) -> std:: io:: Result < Self > {
169+ fn new_from_dirfd ( dir_fd : & DirFd , full_path : & Path ) -> std:: io:: Result < Self > {
174170 // Get metadata for the directory itself using fstat
175171 let safe_metadata = dir_fd. metadata ( ) ?;
176172
@@ -361,7 +357,7 @@ fn safe_du(
361357 Err ( _e) => {
362358 // Try using our new DirFd method for the root directory
363359 match DirFd :: open ( path) {
364- Ok ( dir_fd) => match Stat :: new_from_dirfd ( & dir_fd, path, options ) {
360+ Ok ( dir_fd) => match Stat :: new_from_dirfd ( & dir_fd, path) {
365361 Ok ( s) => s,
366362 Err ( e) => {
367363 let error = e. map_err_context (
@@ -446,23 +442,19 @@ fn safe_du(
446442 // Handle symlinks with -L option
447443 // For safe traversal with -L, we skip symlinks to directories entirely
448444 // and let the non-safe traversal handle them at the top level
449- let ( entry_stat , is_dir ) = if is_symlink && options. dereference == Deref :: All {
445+ if is_symlink && options. dereference == Deref :: All {
450446 // Skip symlinks to directories when using safe traversal with -L
451447 // They will be handled by regular traversal
452448 continue ;
453- } else {
454- let is_dir = ( lstat. st_mode & S_IFMT ) == S_IFDIR ;
455- ( lstat, is_dir)
456- } ;
449+ }
457450
458- let file_info = if entry_stat. st_ino != 0 {
459- Some ( FileInfo {
460- file_id : entry_stat. st_ino as u128 ,
461- dev_id : entry_stat. st_dev ,
462- } )
463- } else {
464- None
465- } ;
451+ let is_dir = ( lstat. st_mode & S_IFMT ) == S_IFDIR ;
452+ let entry_stat = lstat;
453+
454+ let file_info = ( entry_stat. st_ino != 0 ) . then_some ( FileInfo {
455+ file_id : entry_stat. st_ino as u128 ,
456+ dev_id : entry_stat. st_dev ,
457+ } ) ;
466458
467459 // For safe traversal, we need to handle stats differently
468460 // We can't use std::fs::Metadata since that requires the full path
@@ -723,18 +715,9 @@ fn du_regular(
723715 }
724716 }
725717 Err ( e) => {
726- // Check if this is the "too many symlinks" error we want to catch
727- if e. kind ( ) == std:: io:: ErrorKind :: InvalidData
728- && e. to_string ( ) . contains ( "Too many levels" )
729- {
730- print_tx. send ( Err ( e. map_err_context (
718+ print_tx. send ( Err ( e. map_err_context (
731719 || translate ! ( "du-error-cannot-access" , "path" => entry_path. quote( ) ) ,
732720 ) ) ) ?;
733- } else {
734- print_tx. send ( Err ( e. map_err_context (
735- || translate ! ( "du-error-cannot-access" , "path" => entry_path. quote( ) ) ,
736- ) ) ) ?;
737- }
738721 }
739722 }
740723 }
0 commit comments