mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-15919 minor tmpfile cleanup fixes
This commit is contained in:
parent
7c53e3e5de
commit
d4858e5cd1
1 changed files with 3 additions and 0 deletions
|
@ -211,10 +211,12 @@ class file_packer {
|
||||||
// large file, would not fit into memory :-(
|
// large file, would not fit into memory :-(
|
||||||
$tmpfile = tempnam($CFG->dataroot.'/temp/unzip', 'largefile');
|
$tmpfile = tempnam($CFG->dataroot.'/temp/unzip', 'largefile');
|
||||||
if (!$fp = fopen($tmpfile, 'wb')) {
|
if (!$fp = fopen($tmpfile, 'wb')) {
|
||||||
|
@unlink($tmpfile);
|
||||||
$processed[$name] = 'Can not write temp file'; // TODO: localise
|
$processed[$name] = 'Can not write temp file'; // TODO: localise
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$fz = $zip->getStream($index['name'])) {
|
if (!$fz = $zip->getStream($index['name'])) {
|
||||||
|
@unlink($tmpfile);
|
||||||
$processed[$name] = 'Can not read file from zip archive'; // TODO: localise
|
$processed[$name] = 'Can not read file from zip archive'; // TODO: localise
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +235,7 @@ class file_packer {
|
||||||
|
|
||||||
if ($file = $fs->get_file($contextid, $filearea, $itemid, $filepath, $filename)) {
|
if ($file = $fs->get_file($contextid, $filearea, $itemid, $filepath, $filename)) {
|
||||||
if (!$file->delete()) {
|
if (!$file->delete()) {
|
||||||
|
@unlink($tmpfile);
|
||||||
$processed[$name] = 'Can not delete existing file'; // TODO: localise
|
$processed[$name] = 'Can not delete existing file'; // TODO: localise
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue