Stop overriding real path when pasting into existing partitions (#766349)
When composing a copy operation it always named the destination partition as "copy of /dev/SRC". For the case of pasting into unallocated space creating a new partition this was the right thing to do as the partition doesn't yet exist so the path is not yet known. However for the case of pasting into an existing partition the path is known and replacing it with "copy of /dev/SRC" is wrong. No other operation when operating on an existing partition changes it path. Given a set of existing partitions, sdb1 to sdb4, compose a set of copy operations as: copy sdb1 to sdb2, copy sdb2 to sdb3 and copy sdb3 to sdb4. The displayed partitions before being applied become: /dev/sdb1 copy of /dev/sdb1 copy of copy of /dev/sdb1 copy of copy of copy of /dev/sdb1 And the pending operations are named: Copy /dev/sdb1 to /dev/sdb2 Copy copy of /dev/sdb1 to /dev/sdb3 Copy copy of copy of /dev/sdb1 to /sev/sdb4 This is perverse. In the case of pasting into an existing partition keep the real path name. This keeps the partitions being displayed as: /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4 And the pending operations named as: Copy /dev/sdb1 to /dev/sdb2 Copy /dev/sdb2 to /dev/sdb3 Copy /dev/sdb3 to /dev/sdb4 Much more understandable. Also switch to an upper case "C" in "Copy of /dev/SRC" as the temporary path name when pasting into unallocated space. Finally update the comment in calibrate_partition() to describe the remaining cases when re-adding the path is still required. Bug 766349 - Resolve code ugliness with partition path getting set to "copy of /dev/SRC"
This commit is contained in:
parent
7bf8760346
commit
302cc8041e
|
@ -3461,23 +3461,23 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
|
||||||
{
|
{
|
||||||
// Re-add the real partition path from libparted.
|
// Re-add the real partition path from libparted.
|
||||||
//
|
//
|
||||||
// When creating a copy operation the list of
|
// When creating a copy operation by pasting into
|
||||||
// paths for the partition object was set to
|
// unallocated space the list of paths for the
|
||||||
// ["copy of /dev/SRC"] to display in the UI
|
// partition object was set to
|
||||||
// before the operations are applied. When
|
// ["Copy of /dev/SRC"] because the partition
|
||||||
// pasting into an existing partition, this
|
// didn't yet exist before the operations were
|
||||||
// re-adds the real path to the start of the list
|
// applied. Additional operations on that new
|
||||||
// making it ["/dev/DST", "copy of /dev/SRC"].
|
// partition also got the list of paths set to
|
||||||
// This provides the real path for any file system
|
// ["Copy of /dev/SRC"]. This re-adds the real
|
||||||
// specific tools needed during the copy
|
// path to the start of the list making it
|
||||||
// operation. Such as file system check and grow
|
// ["/dev/NEW", "Copy of /dev/SRC"]. This
|
||||||
// steps added when the source and destination
|
// provides the real path for file system specific
|
||||||
// aren't identical sizes or when file system
|
// tools used during those additional operations
|
||||||
// specific tools are used to perform the copy as
|
// such mkfs for the format operation or fsck and
|
||||||
// for XFS or recent EXT2/3/4 tools.
|
// others for the resize/move operation.
|
||||||
//
|
//
|
||||||
// FIXME: Having this work just because "/dev/DST"
|
// FIXME: Having this work just because "/dev/NEW"
|
||||||
// happens to sort before "copy of /dev/SRC" is
|
// happens to sort before "Copy of /dev/SRC" is
|
||||||
// ugly! Probably have a separate display path
|
// ugly! Probably have a separate display path
|
||||||
// which can be changed at will without affecting
|
// which can be changed at will without affecting
|
||||||
// the list of real paths for the partition.
|
// the list of real paths for the partition.
|
||||||
|
|
|
@ -33,9 +33,6 @@ OperationCopy::OperationCopy( const Device & device,
|
||||||
this->partition_original = partition_orig.clone();
|
this->partition_original = partition_orig.clone();
|
||||||
this->partition_new = partition_new.clone();
|
this->partition_new = partition_new.clone();
|
||||||
this->partition_copied = partition_copied.clone();
|
this->partition_copied = partition_copied.clone();
|
||||||
|
|
||||||
this->partition_new->add_path(
|
|
||||||
String::ucompose( _("copy of %1"), this->partition_copied->get_path() ), true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationCopy::~OperationCopy()
|
OperationCopy::~OperationCopy()
|
||||||
|
|
|
@ -1857,6 +1857,15 @@ void Win_GParted::activate_paste()
|
||||||
*copied_partition );
|
*copied_partition );
|
||||||
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
// When pasting into unallocated space set a temporary
|
||||||
|
// path of "Copy of /dev/SRC" for display purposes until
|
||||||
|
// the partition is created and the real path queried.
|
||||||
|
OperationCopy * copy_op = static_cast<OperationCopy*>( operation );
|
||||||
|
copy_op->get_partition_new().add_path(
|
||||||
|
String::ucompose( _("Copy of %1"),
|
||||||
|
copy_op->get_partition_copied().get_path() ),
|
||||||
|
true );
|
||||||
|
|
||||||
Add_Operation( operation ) ;
|
Add_Operation( operation ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue