Skip to content

Commit

Permalink
MDL-37774 Make moodle1_file_manager::migrate_directory() support trai…
Browse files Browse the repository at this point in the history
…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 10, 2013
1 parent 68c1945 commit e2f455b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backup/converter/moodle1/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1274,6 +1274,11 @@ public function migrate_file($sourcepath, $filepath = '/', $filename = null, $so
*/ */
public function migrate_directory($rootpath, $relpath='/') { 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)) { if (!file_exists($this->basepath.'/'.$rootpath.$relpath)) {
return array(); return array();
} }
Expand Down

0 comments on commit e2f455b

Please sign in to comment.