diff --git a/include/Copy_Blocks.h b/include/Copy_Blocks.h index cfecd7b0..17d9fdd9 100644 --- a/include/Copy_Blocks.h +++ b/include/Copy_Blocks.h @@ -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(); diff --git a/src/Copy_Blocks.cc b/src/Copy_Blocks.cc index 79f6cb6b..e9e7587f 100644 --- a/src/Copy_Blocks.cc +++ b/src/Copy_Blocks.cc @@ -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; } diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 3ce1dea1..fb786efb 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -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(