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
This commit is contained in:
Mike Fleetwood 2017-11-26 13:08:15 +00:00 committed by Curtis Gedak
parent 2040aabd22
commit b4cd5da4f7
1 changed files with 4 additions and 4 deletions

View File

@ -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 );
}
}