@@ -152,31 +152,33 @@ impl Traversal {
152152 }
153153
154154 let ( entry_tx, entry_rx) = crossbeam:: channel:: bounded ( 100 ) ;
155- let walk_options_clone = walk_options. clone ( ) ;
156155 std:: thread:: Builder :: new ( )
157156 . name ( "dua-fs-walk-dispatcher" . to_string ( ) )
158- . spawn ( move || {
159- for path in input. into_iter ( ) {
160- let device_id = match crossdev:: init ( path. as_ref ( ) ) {
161- Ok ( id) => id,
162- Err ( _) => {
163- t. io_errors += 1 ;
164- continue ;
165- }
166- } ;
167- let shared_path = Arc :: new ( path) ;
157+ . spawn ( {
158+ let walk_options = walk_options. clone ( ) ;
159+ move || {
160+ for root_path in input. into_iter ( ) {
161+ let device_id = match crossdev:: init ( root_path. as_ref ( ) ) {
162+ Ok ( id) => id,
163+ Err ( _) => {
164+ t. io_errors += 1 ;
165+ continue ;
166+ }
167+ } ;
168168
169- for entry in walk_options_clone
170- . iter_from_path ( shared_path. as_ref ( ) , device_id)
171- . into_iter ( )
172- {
173- if entry_tx
174- . send ( ( entry, Arc :: clone ( & shared_path) , device_id) )
175- . is_err ( )
169+ let root_path = Arc :: new ( root_path) ;
170+ for entry in walk_options
171+ . iter_from_path ( root_path. as_ref ( ) , device_id)
172+ . into_iter ( )
176173 {
177- // The channel is closed, this means the user has
178- // requested to quit the app. Abort the walking.
179- return ;
174+ if entry_tx
175+ . send ( ( entry, Arc :: clone ( & root_path) , device_id) )
176+ . is_err ( )
177+ {
178+ // The channel is closed, this means the user has
179+ // requested to quit the app. Abort the walking.
180+ return ;
181+ }
180182 }
181183 }
182184 }
@@ -185,7 +187,7 @@ impl Traversal {
185187 loop {
186188 crossbeam:: select! {
187189 recv( entry_rx) -> entry => {
188- let Ok ( ( entry, path , device_id) ) = entry else {
190+ let Ok ( ( entry, root_path , device_id) ) = entry else {
189191 break ;
190192 } ;
191193
@@ -194,7 +196,7 @@ impl Traversal {
194196 match entry {
195197 Ok ( entry) => {
196198 data. name = if entry. depth < 1 {
197- ( * path ) . clone( )
199+ ( * root_path ) . clone( )
198200 } else {
199201 entry. file_name. into( )
200202 } ;
@@ -289,7 +291,7 @@ impl Traversal {
289291 }
290292 Err ( _) => {
291293 if previous_depth == 0 {
292- data. name = ( * path ) . clone( ) ;
294+ data. name = ( * root_path ) . clone( ) ;
293295 let entry_index = t. tree. add_node( data) ;
294296 t. tree. add_edge( parent_node_idx, entry_index, ( ) ) ;
295297 }
0 commit comments