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
This commit is contained in:
Mike Fleetwood 2018-09-04 07:32:09 +01:00 committed by Curtis Gedak
parent f098cd414c
commit 4c3f4e3459
1 changed files with 22 additions and 14 deletions

View File

@ -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();
}