Commit f9ed695f authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'B6929-savePdf-copy-instead-of-move' into 'master'

B6929 - Treat single file argument like several file argument (savePdf: copy,…

See merge request !94
parents cba1abd2 7a6b570b
Pipeline #1014 passed with stage
in 1 minute and 37 seconds
...@@ -795,7 +795,7 @@ class Save { ...@@ -795,7 +795,7 @@ class Save {
} }
$overwrite = isset($formElement[FE_FILE_REPLACE_MODE]) && $formElement[FE_FILE_REPLACE_MODE] == FE_FILE_REPLACE_MODE_ALWAYS; $overwrite = isset($formElement[FE_FILE_REPLACE_MODE]) && $formElement[FE_FILE_REPLACE_MODE] == FE_FILE_REPLACE_MODE_ALWAYS;
Support::copyFile($srcFile, $pathFileName, $overwrite, $chmodDir); Support::moveFile($srcFile, $pathFileName, $overwrite, $chmodDir);
// If given, get chmodFile. Needs to be prefixed with a 0 (=octal) - it should not be quoted! Symbolic mode is not allowed. E.g.: 0660, or 01777 // If given, get chmodFile. Needs to be prefixed with a 0 (=octal) - it should not be quoted! Symbolic mode is not allowed. E.g.: 0660, or 01777
if (empty($formElement[FE_FILE_CHMOD_FILE])) { if (empty($formElement[FE_FILE_CHMOD_FILE])) {
......
...@@ -1282,8 +1282,7 @@ class Support { ...@@ -1282,8 +1282,7 @@ class Support {
* @param bool|int $chmodDir , 'false' if not change * @param bool|int $chmodDir , 'false' if not change
* @throws UserFormException * @throws UserFormException
*/ */
public public static function moveFile($srcFile, $pathFileName, $overwrite, $chmodDir = false) {
static function copyFile($srcFile, $pathFileName, $overwrite, $chmodDir = false) {
if (file_exists($pathFileName)) { if (file_exists($pathFileName)) {
if ($overwrite) { if ($overwrite) {
......
...@@ -117,15 +117,9 @@ class Download { ...@@ -117,15 +117,9 @@ class Download {
} }
} }
switch (count($files)) { if (count($files) === 0) return '';
case 0:
return '';
case 1:
return $files[0];
default:
break;
}
// Need to create a separate result file, even if it is just a single file (#6929)
$concatFile = HelperFile::tempnam(); $concatFile = HelperFile::tempnam();
if (false === $concatFile) { if (false === $concatFile) {
throw new DownloadException('Error creating output file.', ERROR_DOWNLOAD_CREATE_NEW_FILE); throw new DownloadException('Error creating output file.', ERROR_DOWNLOAD_CREATE_NEW_FILE);
......
...@@ -812,7 +812,7 @@ class Report { ...@@ -812,7 +812,7 @@ class Report {
} else { } else {
$download = new Download(); $download = new Download();
$file = $download->process($vars, OUTPUT_MODE_FILE); $file = $download->process($vars, OUTPUT_MODE_FILE);
Support::copyFile($file, $pathFileName, true); Support::moveFile($file, $pathFileName, true);
} }
break; break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment