From d4858e5cd10f870f7654ce1ffcbb54d662d88ed2 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 2 Aug 2008 18:49:23 +0000 Subject: [PATCH] MDL-15919 minor tmpfile cleanup fixes --- lib/file/file_packer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/file/file_packer.php b/lib/file/file_packer.php index a3b90c8f05..f5ef80df5f 100644 --- a/lib/file/file_packer.php +++ b/lib/file/file_packer.php @@ -211,10 +211,12 @@ class file_packer { // large file, would not fit into memory :-( $tmpfile = tempnam($CFG->dataroot.'/temp/unzip', 'largefile'); if (!$fp = fopen($tmpfile, 'wb')) { + @unlink($tmpfile); $processed[$name] = 'Can not write temp file'; // TODO: localise continue; } if (!$fz = $zip->getStream($index['name'])) { + @unlink($tmpfile); $processed[$name] = 'Can not read file from zip archive'; // TODO: localise continue; } @@ -233,6 +235,7 @@ class file_packer { if ($file = $fs->get_file($contextid, $filearea, $itemid, $filepath, $filename)) { if (!$file->delete()) { + @unlink($tmpfile); $processed[$name] = 'Can not delete existing file'; // TODO: localise continue; } -- 2.39.5