mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: correctly return false for filesize on non-existing file
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
276ca39a37
commit
e88748e701
2 changed files with 13 additions and 5 deletions
|
|
@ -92,11 +92,15 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
|
|||
}
|
||||
|
||||
public function filesize(string $path): int|float|false {
|
||||
if ($this->is_dir($path)) {
|
||||
return 0; //by definition
|
||||
$type = $this->filetype($path);
|
||||
if ($type === false) {
|
||||
return false;
|
||||
}
|
||||
if ($type !== 'file') {
|
||||
return 0;
|
||||
} else {
|
||||
$stat = $this->stat($path);
|
||||
return isset($stat['size']) ? $stat['size'] : 0;
|
||||
return $stat['size'] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class Local extends \OC\Files\Storage\Common {
|
|||
}
|
||||
|
||||
public function filetype(string $path): string|false {
|
||||
$filetype = filetype($this->getSourcePath($path));
|
||||
$filetype = @filetype($this->getSourcePath($path));
|
||||
if ($filetype == 'link') {
|
||||
$filetype = filetype(realpath($this->getSourcePath($path)));
|
||||
}
|
||||
|
|
@ -223,7 +223,11 @@ class Local extends \OC\Files\Storage\Common {
|
|||
}
|
||||
|
||||
public function filesize(string $path): int|float|false {
|
||||
if (!$this->is_file($path)) {
|
||||
$type = $this->filetype($path);
|
||||
if ($type === false) {
|
||||
return false;
|
||||
}
|
||||
if ($type !== 'file') {
|
||||
return 0;
|
||||
}
|
||||
$fullPath = $this->getSourcePath($path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue