Skip to content
Browse files

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

  • Loading branch information...
1 parent eddceb6 commit bf2d7c1823298aa60d5b5f9d792347d92504ba58 @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 bf2d7c1

Please sign in to comment.
Something went wrong with that request. Please try again.