File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ static OVERALL_PROGRESS: LazyLock<ProgressBar> =
24
24
25
25
thread_local ! {
26
26
static LOCAL_PROGRESS : ProgressBar = {
27
- PROGRESS . insert_before( & OVERALL_PROGRESS , ProgressBar :: new_spinner( ) )
27
+ if rayon:: current_thread_index( ) . is_some( ) {
28
+ PROGRESS . insert_before( & OVERALL_PROGRESS , ProgressBar :: new_spinner( ) )
29
+ } else {
30
+ ProgressBar :: hidden( )
31
+ }
28
32
} ;
29
33
}
30
34
@@ -69,6 +73,11 @@ fn copy(path: &Path, file_type: FileType) -> std::io::Result<()> {
69
73
fn main ( ) {
70
74
LazyLock :: force ( & OPTIONS ) ;
71
75
72
- let file_type = std:: fs:: metadata ( & OPTIONS . src ) . unwrap ( ) . file_type ( ) ;
73
- copy ( "" . as_ref ( ) , file_type) . unwrap ( ) ;
76
+ rayon:: scope ( |s| {
77
+ s. spawn ( |_| {
78
+ OVERALL_PROGRESS . inc_length ( 1 ) ;
79
+ let file_type = std:: fs:: metadata ( & OPTIONS . src ) . unwrap ( ) . file_type ( ) ;
80
+ copy ( "" . as_ref ( ) , file_type) . unwrap ( ) ;
81
+ } ) ;
82
+ } ) ;
74
83
}
You can’t perform that action at this time.
0 commit comments