Skip to content

Commit

Permalink
MDL-64290 backup imscc: Use correct tempdir for imscc restore
Browse files Browse the repository at this point in the history
Use configured temp directory $CFG->tempdir instead of hard coded
$CFG->dataroot . '/temp/backup/'
Remove unused variable, $CFG
  • Loading branch information
mspall committed Dec 5, 2018
1 parent df6d0b6 commit f1a22c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions backup/converter/imscc1/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function log($message, $level, $a = null, $depth = null, $display = false
* @return null|string backup::FORMAT_IMSCC1 if the Common Cartridge 1.0 is detected, null otherwise
*/
public static function detect_format($tempdir) {
global $CFG;

$filepath = $CFG->dataroot . '/temp/backup/' . $tempdir;
$filepath = make_backup_temp_directory($tempdir, false);
if (!is_dir($filepath)) {
throw new convert_helper_exception('tmp_backup_directory_not_found', $filepath);
}
$manifest = cc2moodle::get_manifest($filepath);
if (!empty($manifest)) {
// Looks promising, lets load some information.
Expand Down
7 changes: 4 additions & 3 deletions backup/converter/imscc11/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public function log($message, $level, $a = null, $depth = null, $display = false
* @return null|string backup::FORMAT_IMSCC11 if the Common Cartridge 1.1 is detected, null otherwise
*/
public static function detect_format($tempdir) {
global $CFG;

$filepath = $CFG->dataroot . '/temp/backup/' . $tempdir;
$filepath = make_backup_temp_directory($tempdir, false);
if (!is_dir($filepath)) {
throw new convert_helper_exception('tmp_backup_directory_not_found', $filepath);
}
$manifest = cc112moodle::get_manifest($filepath);
if (file_exists($manifest)) {
// Looks promising, lets load some information.
Expand Down

0 comments on commit f1a22c4

Please sign in to comment.