[gparted/psusi/refactor: 13/16] Don't revert more than needed
- From: Phillip Susi <psusi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/psusi/refactor: 13/16] Don't revert more than needed
- Date: Tue, 29 Jan 2013 03:46:30 +0000 (UTC)
commit e178633882666c06f39d1a67bfcfb661f8b74db4
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 75131d6..ee0d458 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2812,13 +2812,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]