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> =
2424
2525thread_local ! {
2626 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+ }
2832 } ;
2933}
3034
@@ -69,6 +73,11 @@ fn copy(path: &Path, file_type: FileType) -> std::io::Result<()> {
6973fn main ( ) {
7074 LazyLock :: force ( & OPTIONS ) ;
7175
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+ } ) ;
7483}
You can’t perform that action at this time.
0 commit comments