Use a single progress bar for the internal block copy operation (#762367)
As part of the internal block copy operation 5 initial ranges of blocks are copied using different block sizes to determine the fastest. Then the remainder is copied using the fastest block size. Each of these copies reports progress independently, so during the benchmarking phase the progress bar flashes 5 times as it goes from 0 to 100% in a fraction of a second, before showing the progress of the remainder. This looks bad, so report a single progress bar for all the ranges of blocks copied in a single copy operation. Already have variables done and length which track progress within each copied range; and total_done which records amount copied in previous ranges. Just add total_length to allow overall progress to be reported. Bug 762367 - Use a single progress bar for the whole of the internal copy operation
This commit is contained in:
parent
2f2280e3d5
commit
1358a5f4fe
|
@ -32,6 +32,7 @@ class copy_blocks {
|
|||
Byte_Value blocksize;
|
||||
OperationDetail &operationdetail;
|
||||
Byte_Value & total_done;
|
||||
Byte_Value total_length;
|
||||
char *buf;
|
||||
Byte_Value done;
|
||||
PedDevice *lp_device_src;
|
||||
|
@ -54,6 +55,7 @@ public:
|
|||
Byte_Value in_blocksize,
|
||||
OperationDetail & in_operationdetail,
|
||||
Byte_Value & in_total_done,
|
||||
Byte_Value in_total_length,
|
||||
bool cancel_safe );
|
||||
bool copy();
|
||||
void copy_block();
|
||||
|
|
|
@ -41,6 +41,7 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
|
|||
Byte_Value in_blocksize,
|
||||
OperationDetail & in_operationdetail,
|
||||
Byte_Value & in_total_done,
|
||||
Byte_Value in_total_length,
|
||||
bool in_cancel_safe) :
|
||||
src_device( in_src_device ),
|
||||
dst_device ( in_dst_device ),
|
||||
|
@ -48,6 +49,7 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
|
|||
blocksize ( in_blocksize ),
|
||||
operationdetail ( in_operationdetail ),
|
||||
total_done ( in_total_done ),
|
||||
total_length ( in_total_length ),
|
||||
offset_src ( src_start ),
|
||||
offset_dst ( dst_start ),
|
||||
cancel( false ),
|
||||
|
@ -62,7 +64,7 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
|
|||
bool copy_blocks::set_progress_info()
|
||||
{
|
||||
Byte_Value done = llabs(this->done);
|
||||
operationdetail.run_progressbar( (double)done, (double)length, PROGRESSBAR_TEXT_COPY_BYTES );
|
||||
operationdetail.run_progressbar( (double)(total_done+done), (double)total_length, PROGRESSBAR_TEXT_COPY_BYTES );
|
||||
OperationDetail &operationdetail = this->operationdetail.get_last_child().get_last_child();
|
||||
operationdetail.set_description(
|
||||
String::ucompose( /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied */
|
||||
|
@ -154,7 +156,7 @@ bool copy_blocks::copy()
|
|||
String::ucompose( _("copy %1 using a block size of %2"),
|
||||
Utils::format_size( length, 1 ),
|
||||
Utils::format_size( blocksize, 1 ) ) ) );
|
||||
operationdetail.run_progressbar( 0.0, (double)length, PROGRESSBAR_TEXT_COPY_BYTES );
|
||||
operationdetail.run_progressbar( (double)total_done, (double)total_length, PROGRESSBAR_TEXT_COPY_BYTES );
|
||||
|
||||
done = length % blocksize;
|
||||
|
||||
|
@ -190,7 +192,8 @@ bool copy_blocks::copy()
|
|||
else
|
||||
error_message = Glib::strerror( errno );
|
||||
|
||||
operationdetail.stop_progressbar();
|
||||
if ( total_done == total_length || ! success )
|
||||
operationdetail.stop_progressbar();
|
||||
operationdetail.get_last_child().set_status( success ? STATUS_SUCCES : STATUS_ERROR );
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -3201,6 +3201,7 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
|
|||
benchmark_blocksize,
|
||||
operationdetail .get_last_child(),
|
||||
total_done,
|
||||
src_length,
|
||||
cancel_safe ).copy();
|
||||
timer.stop() ;
|
||||
|
||||
|
@ -3236,6 +3237,7 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
|
|||
optimal_blocksize,
|
||||
operationdetail,
|
||||
total_done,
|
||||
src_length,
|
||||
cancel_safe ).copy();
|
||||
|
||||
operationdetail .add_child( OperationDetail(
|
||||
|
|
Loading…
Reference in New Issue