Browse files

MDL-32012 resource: flaw in restore from moodle 1.9 backups

  • Loading branch information...
1 parent 446dbee commit d68cf3877c75a7230446a86c30766f0456af64ad @merrill-oakland merrill-oakland committed Apr 20, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 mod/resource/backup/moodle1/lib.php
View
11 mod/resource/backup/moodle1/lib.php
@@ -191,8 +191,17 @@ public function process_resource(array $data, array $raw) {
}
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
+
+ // Rebuild the file path.
+ $curfilepath = '/';
+ if ($reference) {
+ $curfilepath = pathinfo('/'.$reference, PATHINFO_DIRNAME);
+ if ($curfilepath != '/') {
+ $curfilepath .= '/';
+ }
+ }
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) {
// the file probably does not exist
$this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);

0 comments on commit d68cf38

Please sign in to comment.