fn update_progress_bars(m: &MultiProgress, bars: &[ProgressBar], status: &FilesGetStatus) {
    let b_onefile = status.file_size == status.total_transfer_bytes;

    // do some setup if the transfer is just starting.
    if status.transfer_bytes_written == 0 {
        // Hide bar1 if we are only downloading 1 file in this transfer.
        if b_onefile {
            bars[1].finish_and_clear();
        }
    }

    // set bar 1 length and reset elapsed time when starting a new file.
    if status.file_bytes_written == 0 {
        bars[0].set_length(status.file_size);
        bars[0].reset();

        // We re-set this for each file because it can change if a pre-existing file is preserved.
        bars[2].set_length(status.total_transfer_bytes);

        if !b_onefile {
            bars[1].set_length(status.file_size);
            bars[1].reset();
        }
    }

    let msg = format!(
        "File [{} of {}]: {}",
        status.current_file,
        status.total_files,
        status.path_remote.display().to_string().trim_matches('/')
    );

    // set bar 0 message, and set position for all 3 bars.
    bars[0].set_message(&msg);
    bars[0].set_position(status.file_bytes_written);
    bars[1].set_position(status.file_bytes_written);
    bars[2].set_position(status.transfer_bytes_written);

    // finish bars 0 and 1 when current file has been downloaded.
    if status.file_size == status.file_bytes_written {
        bars[0].finish_at_current_pos();
        bars[1].finish_at_current_pos();
    }

    // Hide bars 0 and 1 when transfer is done.
    if status.total_transfer_bytes == status.transfer_bytes_written {
        bars[0].finish_and_clear();
        bars[1].finish_and_clear();
        bars[2].finish_at_current_pos();
    }
    // tell bar to update/display.
    m.tick(TickTimeLimit::Timeout(Duration::from_millis(50)))
        .unwrap_or(());
}
// Update the progress bars.
// Called once before each file starts downloading,
// and again after each chunk until it finishes.
// Current state can be determined by
//    checking transfer_bvtes_written and file_bytes_written
Update the progress bars.
Called once before each file starts downloading,
and again after each chunk until it finishes.
Current state can be determined by
checking transfer_bvtes_written and file_bytes_written
Update the progress bars . Called once before each file starts downloading and again after each chunk until it finishes . Current state can be determined by checking transfer_bvtes_written and file_bytes_written
fn update_progress_bars(m: &MultiProgress, bars: &[ProgressBar], status: &FilesGetStatus) {
    let b_onefile = status.file_size == status.total_transfer_bytes;
    // do some setup if the transfer is just starting.
    if status.transfer_bytes_written == 0 {
        // Hide bar1 if we are only downloading 1 file in this transfer.
        if b_onefile {
            bars[1].finish_and_clear();
        }
    }
    // set bar 1 length and reset elapsed time when starting a new file.
    if status.file_bytes_written == 0 {
        bars[0].set_length(status.file_size);
        bars[0].reset();
        // We re-set this for each file because it can change if a pre-existing file is preserved.
        bars[2].set_length(status.total_transfer_bytes);
        if !b_onefile {
            bars[1].set_length(status.file_size);
            bars[1].reset();
        }
    }
    let msg = format!(
        "File [{} of {}]: {}",
        status.current_file,
        status.total_files,
        status.path_remote.display().to_string().trim_matches('/')
    );
    // set bar 0 message, and set position for all 3 bars.
    bars[0].set_message(&msg);
    bars[0].set_position(status.file_bytes_written);
    bars[1].set_position(status.file_bytes_written);
    bars[2].set_position(status.transfer_bytes_written);
    // finish bars 0 and 1 when current file has been downloaded.
    if status.file_size == status.file_bytes_written {
        bars[0].finish_at_current_pos();
        bars[1].finish_at_current_pos();
    }
    // Hide bars 0 and 1 when transfer is done.
    if status.total_transfer_bytes == status.transfer_bytes_written {
        bars[0].finish_and_clear();
        bars[1].finish_and_clear();
        bars[2].finish_at_current_pos();
    }
    // tell bar to update/display.
    m.tick(TickTimeLimit::Timeout(Duration::from_millis(50)))
        .unwrap_or(());
}
fn update_progress_bars ( m : & MultiProgress , bars : & [ ProgressBar ] , status : & FilesGetStatus ) { let b_onefile = status . file_size == status . total_transfer_bytes ; // do some setup if the transfer is just starting. if status . transfer_bytes_written == 0 { // Hide bar1 if we are only downloading 1 file in this transfer. if b_onefile { bars [ 1 ] . finish_and_clear ( ) ; } } // set bar 1 length and reset elapsed time when starting a new file. if status . file_bytes_written == 0 { bars [ 0 ] . set_length ( status . file_size ) ; bars [ 0 ] . reset ( ) ; // We re-set this for each file because it can change if a pre-existing file is preserved. bars [ 2 ] . set_length ( status . total_transfer_bytes ) ; if ! b_onefile { bars [ 1 ] . set_length ( status . file_size ) ; bars [ 1 ] . reset ( ) ; } } let msg = format ! ( " " status current_file status total_files status path_remote display ( ) to_string ( ) trim_matches ( '/' ) ) ; // set bar 0 message, and set position for all 3 bars. bars [ 0 ] . set_message ( & msg ) ; bars [ 0 ] . set_position ( status . file_bytes_written ) ; bars [ 1 ] . set_position ( status . file_bytes_written ) ; bars [ 2 ] . set_position ( status . transfer_bytes_written ) ; // finish bars 0 and 1 when current file has been downloaded. if status . file_size == status . file_bytes_written { bars [ 0 ] . finish_at_current_pos ( ) ; bars [ 1 ] . finish_at_current_pos ( ) ; } // Hide bars 0 and 1 when transfer is done. if status . total_transfer_bytes == status . transfer_bytes_written { bars [ 0 ] . finish_and_clear ( ) ; bars [ 1 ] . finish_and_clear ( ) ; bars [ 2 ] . finish_at_current_pos ( ) ; } // tell bar to update/display. m . tick ( TickTimeLimit :: Timeout ( Duration :: from_millis ( 50 ) ) ) . unwrap_or ( ( ) ) ; }
Update the progress bars.
Update the progress bars .
m
&MultiProgress
bars
&[ProgressBar]
status
&FilesGetStatus