MDL-77467 retore: add progress tracking to potentially slow steps

This commit is contained in:
Tim Hunt 2023-03-01 18:06:53 +00:00
parent 9ee4f8db8b
commit 497c527e98
3 changed files with 18 additions and 3 deletions

View File

@ -767,6 +767,7 @@ class restore_decode_interlinks extends restore_execution_step {
protected function define_execution() {
// Get the decoder (from the plan)
/** @var restore_decode_processor $decoder */
$decoder = $this->task->get_decoder();
restore_decode_processor::register_link_decoders($decoder); // Add decoder contents and rules
// And launch it, everything will be processed
@ -5503,17 +5504,22 @@ class restore_process_file_aliases_queue extends restore_execution_step {
protected function define_execution() {
global $DB;
$this->log('processing file aliases queue', backup::LOG_DEBUG);
$fs = get_file_storage();
// Load the queue.
$aliascount = $DB->count_records('backup_ids_temp',
['backupid' => $this->get_restoreid(), 'itemname' => 'file_aliases_queue']);
$rs = $DB->get_recordset('backup_ids_temp',
array('backupid' => $this->get_restoreid(), 'itemname' => 'file_aliases_queue'),
['backupid' => $this->get_restoreid(), 'itemname' => 'file_aliases_queue'],
'', 'info');
$this->log('processing file aliases queue. ' . $aliascount . ' entries.', backup::LOG_DEBUG);
$progress = $this->task->get_progress();
$progress->start_progress('Processing file aliases queue', $aliascount);
// Iterate over aliases in the queue.
foreach ($rs as $record) {
$progress->increment_progress();
$info = backup_controller_dbops::decode_backup_temp_info($record->info);
// Try to pick a repository instance that should serve the alias.
@ -5638,6 +5644,7 @@ class restore_process_file_aliases_queue extends restore_execution_step {
}
}
}
$progress->end_progress();
$rs->close();
}

View File

@ -77,6 +77,7 @@ class restore_decode_processor {
*/
public function execute() {
// Iterate over all contents, visiting them
/** @var restore_decode_content $content */
foreach ($this->contents as $content) {
$content->process($this);
}

View File

@ -201,9 +201,16 @@ class restore_plan extends base_plan implements loggable {
*/
public function execute_after_restore() {
// Simply iterate over each task in the plan and delegate to them the execution
$progress = $this->get_progress();
$progress->start_progress($this->get_name() .
': executing execute_after_restore for all tasks', count($this->tasks));
/** @var base_task $task */
foreach ($this->tasks as $task) {
$task->execute_after_restore();
$progress->increment_progress();
}
$progress->end_progress();
}
}