Merge branch 'MDL-40440-m' of git://github.com/andrewnicols/moodle

This commit is contained in:
Damyon Wiese 2013-07-15 14:42:10 +08:00
commit d7bf5fd1f7

View File

@ -949,21 +949,25 @@ abstract class restore_dbops {
} else {
// This backup does not include the files - they should be available in moodle filestorage already.
// Even if a file has been deleted since the backup was made, the file metadata will remain in the
// files table, and the file will not be moved to the trashdir.
// Files are not cleared from the files table by cron until several days after deletion.
if ($foundfiles = $DB->get_records('files', array('contenthash' => $file->contenthash))) {
// Only grab one of the foundfiles - the file content should be the same for all entries.
$foundfile = reset($foundfiles);
$fs->create_file_from_storedfile($file_record, $foundfile->id);
} else {
// A matching existing file record was not found in the database.
$result = new stdClass();
$result->code = 'file_missing_in_backup';
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
$result->level = backup::LOG_WARNING;
$results[] = $result;
continue;
// Create the file in the filepool if it does not exist yet.
if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) {
// Even if a file has been deleted since the backup was made, the file metadata will remain in the
// files table, and the file will not be moved to the trashdir.
// Files are not cleared from the files table by cron until several days after deletion.
if ($foundfiles = $DB->get_records('files', array('contenthash' => $file->contenthash))) {
// Only grab one of the foundfiles - the file content should be the same for all entries.
$foundfile = reset($foundfiles);
$fs->create_file_from_storedfile($file_record, $foundfile->id);
} else {
// A matching existing file record was not found in the database.
$result = new stdClass();
$result->code = 'file_missing_in_backup';
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
$result->level = backup::LOG_WARNING;
$results[] = $result;
continue;
}
}
}