[gparted] Set OperationDetail status last during internal copy benchmarking (#790842)



commit e5ccb3b8bc2ad3bf1c06c41bc8a97bcf5c11e27d
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Dec 10 14:18:36 2017 +0000

    Set OperationDetail status last during internal copy benchmarking (#790842)
    
    Performing a copy or move operation which uses GParted's internal copy
    routine triggered the new GParted bug message.  Example operation
    details:
    
      Copy /dev/sdb8 to /dev/sdb (start at 4.51 GiB)               (SUCESSS)
      * calibrate /dev/sdb8                                        (SUCCESS)
      * check file system on /dev/sdb8 for errors and (if possib...(SUCCESS)
      * create empty partition                                     (SUCCESS)
      * set partition type on /dev/sdb9                            (SUCCESS)
      * copy file system from /dev/sdb8 to /dev/sdb9               (SUCCESS)
          using internal algorithm
          copy 1.00 GiB
        * finding optimal block size
          * copy 16.00 MiB using a block size of 1.00 MiB          (SUCCESS)
              16.00 MiB of 16.00 MiB copied
              GParted Bug: Adding more information to the result...(WARNING)
              0.797269 seconds
          * copy 16.00 MiB using a block size of 2.00 MiB          (SUCCESS)
          * copy 16.00 MiB using a block size of 4.00 MiB          (SUCCESS)
          * copy 16.00 MiB using a block size of 8.00 MiB          (SUCCESS)
          * copy 16.00 MiB using a block size of 16.00 MiB         (SUCCESS)
            optimal block size is 1.00 MiB
        * copy 944.00 MiB using a block size of 1.00 MiB           (SUCCESS)
    
    This is because when performing the initial benchmarking copies the time
    taken by each copy is added to the operation detail results in the
    calling GParted_Core::copy_blocks() after the final status was set in
    CopyBlocks::copy() with set_success_and_capture_errors().  Fix by
    setting the final status in the parent function after adding the time to
    the benchmark copies.
    
    Bug 790842 - Report libparted messages into operation details at the
                 point at which they occur

 src/CopyBlocks.cc   |    2 +-
 src/GParted_Core.cc |    4 ++++
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/CopyBlocks.cc b/src/CopyBlocks.cc
index 360157c..f25c0c1 100644
--- a/src/CopyBlocks.cc
+++ b/src/CopyBlocks.cc
@@ -193,7 +193,7 @@ bool CopyBlocks::copy()
 
        if ( total_done == total_length || ! success )
                operationdetail.stop_progressbar();
-       operationdetail.get_last_child().set_success_and_capture_errors( success );
+
        return success;
 }
 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 7d70256..bde3c37 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -3244,6 +3244,7 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
 
                operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( 
                        String::ucompose( _("%1 seconds"), timer .elapsed() ), STATUS_NONE, FONT_ITALIC ) ) ;
+               operationdetail.get_last_child().get_last_child().set_success_and_capture_errors( succes );
 
                if ( timer .elapsed() <= smallest_time )
                {
@@ -3266,6 +3267,7 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
                                STATUS_NONE ) ) ;
 
        if ( succes && llabs( done ) < src_length )
+       {
                succes = CopyBlocks( src_device,
                                     dst_device,
                                     src_start + ((done > 0 ? done : 0) / src_sector_size),
@@ -3276,6 +3278,8 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
                                     total_done,
                                     src_length,
                                     cancel_safe ).copy();
+               operationdetail.get_last_child().set_success_and_capture_errors( succes );
+       }
 
        operationdetail .add_child( OperationDetail( 
                String::ucompose( /*TO TRANSLATORS: looks like  1.00 MiB (1048576 B) copied */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]