Display progress of NTFS file system specific copy operation (#762366)
Copying of ntfs is performed using ntfsclone, which writes progress indication to standard output like this: # ntfsclone -f /dev/sdb2 /dev/sdb1 2> /dev/null NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 21474832384 bytes (21475 MB) Current device size: 21474836480 bytes (21475 MB) Scanning volume ... 100.00 percent completed Accounting clusters ... Space in use : 1832 MB (8.5%) Cloning NTFS ... 100.00 percent completed Syncing ... Add ntfsclone progress tracker for ntfsclone command. Deliberately doesn't stop the progress bar. See comment in ntfs::clone_progress() for the explanation. Bug 762366 - Add progress bar to NTFS file system specific copy method
This commit is contained in:
parent
b04ce3e312
commit
6d28a62077
|
@ -46,6 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
void resize_progress( OperationDetail *operationdetail );
|
||||
void clone_progress( OperationDetail *operationdetail );
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
20
src/ntfs.cc
20
src/ntfs.cc
|
@ -260,7 +260,8 @@ bool ntfs::copy( const Partition & src_part,
|
|||
{
|
||||
return ! execute_command( "ntfsclone -f --overwrite " + dest_part.get_path() + " " + src_part.get_path(),
|
||||
operationdetail,
|
||||
EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE );
|
||||
EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE|EXEC_PROGRESS_STDOUT,
|
||||
static_cast<StreamSlot>( sigc::mem_fun( *this, &ntfs::clone_progress ) ) );
|
||||
}
|
||||
|
||||
bool ntfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
|
||||
|
@ -295,4 +296,21 @@ void ntfs::resize_progress( OperationDetail *operationdetail )
|
|||
}
|
||||
}
|
||||
|
||||
void ntfs::clone_progress( OperationDetail *operationdetail )
|
||||
{
|
||||
Glib::ustring line = Utils::last_line( output );
|
||||
// Text progress on the LAST LINE looks like " 15.24 progress completed"
|
||||
float percent;
|
||||
if ( line.find( "percent completed" ) != line.npos && sscanf( line.c_str(), "%f", &percent ) == 1 )
|
||||
{
|
||||
operationdetail->run_progressbar( percent, 100.0 );
|
||||
}
|
||||
// Deliberately don't stop the progress bar when ntfsclone outputs "Syncing ..."
|
||||
// at the end as that is considered a measured part of the copy operation. The
|
||||
// progress bar will wait at 100% (or just below) until the sync completes. On
|
||||
// spinning rust that is typically a few seconds and on SSDs it won't be noticed
|
||||
// at all. Instead it is left for execute_command(), which always stops the
|
||||
// progress bar when the command finishes.
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in New Issue