[gparted/psusi/refactor: 14/19] Don't revert more than needed
- From: Phillip Susi <psusi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/psusi/refactor: 14/19] Don't revert more than needed
- Date: Fri, 22 Feb 2013 01:53:45 +0000 (UTC)
commit 95313ec7f5404b5394ce34b7b3405fcfafade224
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 2c319a2..c6478c0 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2813,13 +2813,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]