Skip to content

Commit

Permalink
MDL-32012 resource: flaw in restore from moodle 1.9 backups
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmerrill committed Apr 27, 2012
1 parent 446dbee commit d68cf38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mod/resource/backup/moodle1/lib.php
Expand Up @@ -191,8 +191,17 @@ public function process_resource(array $data, array $raw) {
} }
$this->fileman->filearea = 'content'; $this->fileman->filearea = 'content';
$this->fileman->itemid = 0; $this->fileman->itemid = 0;

// Rebuild the file path.
$curfilepath = '/';
if ($reference) {
$curfilepath = pathinfo('/'.$reference, PATHINFO_DIRNAME);
if ($curfilepath != '/') {
$curfilepath .= '/';
}
}
try { try {
$this->fileman->migrate_file('course_files/'.$reference, '/', null, 1); $this->fileman->migrate_file('course_files/'.$reference, $curfilepath, null, 1);
} catch (moodle1_convert_exception $e) { } catch (moodle1_convert_exception $e) {
// the file probably does not exist // the file probably does not exist
$this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference); $this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);
Expand Down

0 comments on commit d68cf38

Please sign in to comment.