[gparted] Set the status last for the OperationDetails in mk/rm_temp_dir() (#790842)



commit b4cd5da4f7ff10f4eb7f9ea923491666b3bfea63
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Nov 26 13:08:15 2017 +0000

    Set the status last for the OperationDetails in mk/rm_temp_dir() (#790842)
    
    Resizing any unmounted file system which has to be mounted to be resized
    triggered the new GParted bug message.  However the operation did
    complete successfully.  Example operation details:
    
      Grow /dev/sdb8 from 1.00 GiB to 1.50 GiB                     (SUCCESS)
      * calibrate /dev/sdb
      * check file system on /dev/sdb8 for errors and (if possib...(SUCCESS)
      * grow partition from 1.00 GiB to 1.50 GiB                   (SUCCESS)
      * grow file system to fill the partition                     (SUCCESS)
        * mkdir -v /tmp/gparted-wvH0Ez                             (SUCCESS)
          * GParted Bug: Adding another child after no_more_chil...(ERROR)
          * Created directory /tmp/gparted-wvH0Ez
        * mount -v -t btrfs '/dev/sdb8' '/tmp/gparted-wvH0Ez'      (SUCCESS)
        * btrfs filesystem resize 1:max '/tmp/gparted-wvH0Ez'      (SUCCESS)
        * umount -v '/tmp/gparted-wvH0Ez'                          (SUCCESS)
        * rmdir -v /tmp/gparted-wvH0Ez                             (SUCCESS)
          * GParted Bug: Adding another child after no_more_chil...(ERROR)
          * Removed directory /tmp/gparted-wvH0Ez
    
    This is because set_success_and_capture_errors() was called first and
    the child details added after.  Reverse this ordering to fix.
    
    Bug 790842 - Report libparted messages into operation details at the
                 point at which they occur

 src/FileSystem.cc |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/FileSystem.cc b/src/FileSystem.cc
index dfdc356..19e8277 100644
--- a/src/FileSystem.cc
+++ b/src/FileSystem.cc
@@ -210,9 +210,9 @@ Glib::ustring FileSystem::mk_temp_dir( const Glib::ustring & infix, OperationDet
        if ( NULL == dir_name )
        {
                int e = errno ;
-               operationdetail.get_last_child().set_success_and_capture_errors( false );
                operationdetail .get_last_child() .add_child( OperationDetail(
                                String::ucompose( "mkdtemp(%1): %2", dir_buf, Glib::strerror( e ) ), 
STATUS_NONE ) ) ;
+               operationdetail.get_last_child().set_success_and_capture_errors( false );
                dir_name = "" ;
        }
        else
@@ -220,10 +220,10 @@ Glib::ustring FileSystem::mk_temp_dir( const Glib::ustring & infix, OperationDet
                //Update command with actually created temporary directory
                operationdetail .get_last_child() .set_description(
                                Glib::ustring( "mkdir -v " ) + dir_name, FONT_BOLD_ITALIC ) ;
-               operationdetail.get_last_child().set_success_and_capture_errors( true );
                operationdetail .get_last_child() .add_child( OperationDetail(
                                /*TO TRANSLATORS: looks like   Created directory /tmp/gparted-CEzvSp */
                                String::ucompose( _("Created directory %1"), dir_name ), STATUS_NONE ) ) ;
+               operationdetail.get_last_child().set_success_and_capture_errors( true );
        }
 
        return Glib::ustring( dir_name ) ;
@@ -240,16 +240,16 @@ void FileSystem::rm_temp_dir( const Glib::ustring dir_name, OperationDetail & op
                //Don't mark operation as errored just because rmdir
                //  failed.  Set to Warning (N/A) instead.
                int e = errno ;
-               operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
                operationdetail .get_last_child() .add_child( OperationDetail(
                                String::ucompose( "rmdir(%1): ", dir_name ) + Glib::strerror( e ), 
STATUS_NONE ) ) ;
+               operationdetail.get_last_child().set_status( STATUS_N_A );
        }
        else
        {
-               operationdetail.get_last_child().set_success_and_capture_errors( true );
                operationdetail .get_last_child() .add_child( OperationDetail(
                                /*TO TRANSLATORS: looks like   Removed directory /tmp/gparted-CEzvSp */
                                String::ucompose( _("Removed directory %1"), dir_name ), STATUS_NONE ) ) ;
+               operationdetail.get_last_child().set_success_and_capture_errors( true );
        }
 }
 


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