Permalink
Browse files

MDL-37774 Make moodle1_file_manager::migrate_directory() support trai…

…ling slash in rootpath

As the $rootpath is concatenated with the $relpath, we would end with a
path like course_files//file.txt. Such a path is detected as not-valid
later and an error would be thrown.

So the patch makes sure that the trailing slash is cut off.
  • Loading branch information...
mudrd8mz committed Feb 8, 2013
1 parent 68c1945 commit e2f455b8ca3bc805386436cd65bf74b851967af8
Showing with 5 additions and 0 deletions.
  1. +5 −0 backup/converter/moodle1/lib.php
@@ -1274,6 +1274,11 @@ public function migrate_file($sourcepath, $filepath = '/', $filename = null, $so
*/
public function migrate_directory($rootpath, $relpath='/') {
+ // Check the trailing slash in the $rootpath
+ if (substr($rootpath, -1) === '/') {
+ $rootpath = substr($rootpath, 0, strlen($rootpath) - 1);
+ }
+
if (!file_exists($this->basepath.'/'.$rootpath.$relpath)) {
return array();
}

0 comments on commit e2f455b

Please sign in to comment.