[gparted] Don't revert more than needed
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Don't revert more than needed
- Date: Tue, 12 Mar 2013 00:48:42 +0000 (UTC)
commit b1ede01506b4c057d7d408ce150ccc1b0437678b
Author: Phillip Susi <psusi ubuntu com>
Date: Sat Jan 26 23:28:33 2013 -0500
Don't revert more than needed
After a move is canceled or fails, an attempt is made to revert the disk to
its previous state. This was moving back all blocks that had already been
copied. Many of the first blocks copied during a move do not overwrite
any valid data, and so do not need put back after an error, so don't bother
doing so.
src/GParted_Core.cc | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 6d4d280..41b1873 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2819,13 +2819,20 @@ void GParted_Core::rollback_transaction( const Partition & partition_src,
if ( partition_dst .sector_start > partition_src .sector_start )
{
- temp_src .sector_start = temp_src .sector_end - ( (total_done / temp_src
.sector_size) - 1 ) ;
- temp_dst .sector_start = temp_dst .sector_end - ( (total_done / temp_dst
.sector_size) - 1 ) ;
+ Sector distance = partition_dst.sector_start - partition_src.sector_start;
+ temp_src.sector_start = temp_src.sector_end - ( (total_done / temp_src.sector_size) -
1 ) + distance;
+ temp_dst.sector_start = temp_dst.sector_end - ( (total_done / temp_dst.sector_size) -
1 ) + distance;
+ if (temp_src.sector_start > temp_src.sector_end)
+ return; /* nothing has been overwritten yet, so nothing to roll back */
+
}
else
{
- temp_src .sector_end = temp_src .sector_start + ( (total_done / temp_src
.sector_size) - 1 ) ;
- temp_dst .sector_end = temp_dst .sector_start + ( (total_done / temp_dst
.sector_size) - 1 ) ;
+ Sector distance = partition_src.sector_start - partition_dst.sector_start;
+ temp_src.sector_end = temp_src.sector_start + ( (total_done / temp_src.sector_size) -
1 ) - distance;
+ temp_dst.sector_end = temp_dst.sector_start + ( (total_done / temp_dst.sector_size) -
1 ) - distance;
+ if (temp_src.sector_start > temp_src.sector_end)
+ return; /* nothing has been overwritten yet, so nothing to roll back */
}
operationdetail.add_child( OperationDetail( _("roll back last transaction") ) );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]