[gparted] Correctly preview unknown FS usage when pasting into an existing partition (!13)



commit 4c3f4e3459f8787137ffd8cfb265f685a9972009
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Sep 4 07:32:09 2018 +0100

    Correctly preview unknown FS usage when pasting into an existing partition (!13)
    
    When previewing copying a partition of unknown file system usage into an
    existing partition, the usage still shows that of the overwritten file
    system.  This affects existing supported file systems EXFAT, F2FS, MINIX
    and UFS and the new basic supported one too, all for which GParted can't
    read the file system usage.
    
    Handle the case of the source file system usage being unknown and
    explicitly set the copied usage to unknown too.
    
    Closes !13 - Support copying and moving of unsupported partition content

 src/Win_GParted.cc | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 3ac1aac7..16c09254 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2068,24 +2068,32 @@ void Win_GParted::activate_paste()
                        filesystem_ptn_new.set_filesystem_label( copied_filesystem_ptn.get_filesystem_label() 
);
                        filesystem_ptn_new.uuid = copied_filesystem_ptn.uuid;
                        Sector new_size = filesystem_ptn_new.get_sector_length();
-                       if ( copied_filesystem_ptn.get_sector_length() == new_size )
+                       if ( copied_filesystem_ptn.sector_usage_known() )
                        {
-                               // Pasting into same size existing partition, therefore
-                               // only block copy operation will be performed maintaining
-                               // the file system size.
-                               filesystem_ptn_new.set_sector_usage(
-                                       copied_filesystem_ptn.sectors_used + 
copied_filesystem_ptn.sectors_unused,
-                                       copied_filesystem_ptn.sectors_unused );
+                               if ( copied_filesystem_ptn.get_sector_length() == new_size )
+                               {
+                                       // Pasting into same size existing partition, therefore
+                                       // only block copy operation will be performed maintaining
+                                       // the file system size.
+                                       filesystem_ptn_new.set_sector_usage(
+                                               copied_filesystem_ptn.sectors_used + 
copied_filesystem_ptn.sectors_unused,
+                                               copied_filesystem_ptn.sectors_unused );
+                               }
+                               else
+                               {
+                                       // Pasting into larger existing partition, therefore block
+                                       // copy followed by file system grow operations (if
+                                       // supported) will be performed making the file system
+                                       // fill the partition.
+                                       filesystem_ptn_new.set_sector_usage(
+                                               new_size,
+                                               new_size - copied_filesystem_ptn.sectors_used );
+                               }
                        }
                        else
                        {
-                               // Pasting into larger existing partition, therefore block
-                               // copy followed by file system grow operations (if
-                               // supported) will be performed making the file system
-                               // fill the partition.
-                               filesystem_ptn_new.set_sector_usage(
-                                       new_size,
-                                       new_size - copied_filesystem_ptn.sectors_used );
+                               // FS usage of source is unknown so set destination usage unknown too.
+                               filesystem_ptn_new.set_sector_usage( -1, -1 );
                        }
                        filesystem_ptn_new.clear_messages();
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]