Commit 7a6b570b authored by Elias Villiger's avatar Elias Villiger
Browse files

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

B6929 - Treat single file argument like several file argument (savePdf: copy, not move) - refs #6929, closes #6929
parent 8203e8f7
Pipeline #963 passed with stage
in 1 minute and 59 seconds
...@@ -793,7 +793,7 @@ class Save { ...@@ -793,7 +793,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])) {
......
...@@ -1275,8 +1275,7 @@ class Support { ...@@ -1275,8 +1275,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) {
......
...@@ -116,15 +116,9 @@ class Download { ...@@ -116,15 +116,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