MDL-37761 Backup: Do not include files in backups when importing courses/activities

When we import courses or duplicate activities, the deduplicating nature of
the file_storage system means that we don't actually have to include the
real files in the backup - just their metadata from the file table.

The restoration process needs to know not to expect files from the backup
phase so a flag is set in moodle_backup metadata.
This commit is contained in:
Andrew Nicols 2013-05-12 16:53:57 +01:00
parent f1454424b5
commit b1850c12c1
8 changed files with 168 additions and 46 deletions

View file

@ -82,6 +82,25 @@ class backup_controller_testcase extends advanced_testcase {
$newbc = mock_backup_controller::load_controller($bc->get_backupid());
$this->assertTrue($newbc instanceof backup_controller); // This means checksum and load worked ok
}
public function test_backup_controller_include_files() {
// A MODE_GENERAL controller - this should include files
$bc = new mock_backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE,
backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid);
$this->assertEquals($bc->get_include_files(), 1);
// The MODE_IMPORT and MODE_SAMESITE should not include files in the backup.
// A MODE_IMPORT controller
$bc = new mock_backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE,
backup::INTERACTIVE_NO, backup::MODE_IMPORT, $this->userid);
$this->assertEquals($bc->get_include_files(), 0);
// A MODE_SAMESITE controller
$bc = new mock_backup_controller(backup::TYPE_1COURSE, $this->courseid, backup::FORMAT_MOODLE,
backup::INTERACTIVE_NO, backup::MODE_IMPORT, $this->userid);
$this->assertEquals($bc->get_include_files(), 0);
}
}