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

Catch exception on filesize(), return '-' for non existing files.

parent 072cd417
Pipeline #1739 passed with stage
in 2 minutes and 22 seconds
......@@ -108,20 +108,24 @@ class HelperFile {
* @throws UserFormException
*/
public static function getFileStat($pathFileName) {
$vars = array();
$vars = [VAR_FILE_MIME_TYPE => '-', VAR_FILE_SIZE => '-'];
if (empty($pathFileName)) {
return array();
return $vars;
}
$pathFileName = self::correctRelativePathFileName($pathFileName);
if (!file_exists($pathFileName)) {
return array();
return $vars;
}
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileName);
$vars[VAR_FILE_SIZE] = filesize($pathFileName);
try {
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileName);
$vars[VAR_FILE_SIZE] = filesize($pathFileName);
} catch (Exception $e) {
// do nothing
}
return $vars;
}
......
......@@ -837,7 +837,8 @@ class Report {
break;
case COLUMN_FILE_SIZE:
$content .= filesize($columnValue);
$arr = HelperFile::getFileStat($columnValue);
$content .= $arr[VAR_FILE_SIZE] ?? '-';
break;
case COLUMN_NL2BR:
......@@ -1328,7 +1329,7 @@ class Report {
if ($defaultDownload !== '') {
// Action 'Download' needs to be specified at the beginning
// $columnValue = $defaultDownload . "|" . $columnValue;
$columnValue .= $defaultDownload . "|" ;
$columnValue .= $defaultDownload . "|";
}
if ($defaultMode !== '') {
......
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