Skip to content
  • Mike Fleetwood's avatar
    Stop relying on sort order when adding real paths in calibrate (#766349) · b77fef0d
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    Quoting the relevant comments from GParted_Core::calibrate_partition():
        Re-add the real partition path from libparted.
    
        When creating a copy operation by pasting into unallocated space the
        list of paths for the partition object was set to
        ["Copy of /dev/SRC"] because the partition didn't yet exist before
        the operations were applied.  Additional operations on that new
        partition also got the list of paths set to ["Copy of /dev/SRC"].
        This re-adds the real path to the start of the list making it
        ["/dev/NEW", "Copy of /dev/SRC"].  This provides the real path for
        file system specific tools used during those additional operations
        such mkfs for the format operation or fsck and others for the
        resize/move operation.
    
        FIXME: Having this work just because "/dev/NEW" happens to sort
        before "Copy of /dev/SRC" is ugly!  Probably have a separate display
        path which can be changed at will without affecting the list of real
        paths for the partition.
    
    Having a separate display path is overly complicated and unnecessary.
    Just replace the list of paths with the real one reported by libparted
    if it contained "Copy of /dev/SRC", determined by checking if the file
    exists.  Otherwise continue to add the libparted name as an alternate
    path.  Whole disk devices can never be named "Copy of /dev/SRC" because
    they are not partitioned so never created or deleted by GParted, only
    ever written to, hence don't need the extra exists test logic.
    
    Bug 766349 - Resolve code ugliness with partition path getting set to
                 "copy of /dev/SRC"
    b77fef0d