mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-06 16:34:35 +02:00
Detect correctly if an attachment file is not existing.
This commit is contained in:
parent
d3162a0d75
commit
6799ac90e5
1 changed files with 13 additions and 4 deletions
|
@ -88,8 +88,12 @@ class AttachmentHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
$path = $attachment->getPath();
|
||||
$path = $this->pathResolver->placeholderToRealPath($path);
|
||||
$path = $this->pathResolver->placeholderToRealPath($attachment->getPath());
|
||||
|
||||
//realpath does not work with null as argument
|
||||
if ($path === null) {
|
||||
return null;
|
||||
}
|
||||
return realpath($path);
|
||||
}
|
||||
|
||||
|
@ -112,7 +116,7 @@ class AttachmentHelper
|
|||
|
||||
/**
|
||||
* Returns the filesize of the attachments in bytes.
|
||||
* For external attachments, null is returned.
|
||||
* For external attachments or not existing attachments, null is returned.
|
||||
*
|
||||
* @param Attachment $attachment The filesize for which the filesize should be calculated.
|
||||
* @return int|null
|
||||
|
@ -123,7 +127,12 @@ class AttachmentHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
return filesize($this->toAbsoluteFilePath($attachment));
|
||||
if (!$this->isFileExisting($attachment)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$tmp = filesize($this->toAbsoluteFilePath($attachment));
|
||||
return $tmp !== false ? $tmp : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue