diff --git a/lib/private/Preview/HEIC.php b/lib/private/Preview/HEIC.php index e5d73c943a416..64eb48e58dfa8 100644 --- a/lib/private/Preview/HEIC.php +++ b/lib/private/Preview/HEIC.php @@ -12,6 +12,7 @@ use OCP\Files\File; use OCP\Files\FileInfo; use OCP\IImage; +use OCP\Server; use Psr\Log\LoggerInterface; /** @@ -44,8 +45,8 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $tmpPath = $this->getLocalFile($file); if ($tmpPath === false) { - \OC::$server->get(LoggerInterface::class)->error( - 'Failed to get thumbnail for: ' . $file->getPath(), + Server::get(LoggerInterface::class)->error( + 'Failed to get local file to generate thumbnail for: ' . $file->getPath(), ['app' => 'core'] ); return null; diff --git a/lib/private/Preview/Image.php b/lib/private/Preview/Image.php index 69841f079296e..78a402c636a1d 100644 --- a/lib/private/Preview/Image.php +++ b/lib/private/Preview/Image.php @@ -9,6 +9,8 @@ use OCP\Files\File; use OCP\IImage; +use OCP\Server; +use Psr\Log\LoggerInterface; abstract class Image extends ProviderV2 { /** @@ -25,6 +27,13 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $image = new \OCP\Image(); $fileName = $this->getLocalFile($file); + if ($fileName === false) { + Server::get(LoggerInterface::class)->error( + 'Failed to get local file to generate thumbnail for: ' . $file->getPath(), + ['app' => 'core'] + ); + return null; + } $image->loadFromFile($fileName); $image->fixOrientation(); diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php index 105b182b415ae..add0028738e90 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -9,6 +9,8 @@ use OCP\Files\File; use OCP\IImage; +use OCP\Server; +use Psr\Log\LoggerInterface; use wapmorgan\Mp3Info\Mp3Info; use function OCP\Log\logger; @@ -25,6 +27,13 @@ public function getMimeType(): string { */ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $tmpPath = $this->getLocalFile($file); + if ($tmpPath === false) { + Server::get(LoggerInterface::class)->error( + 'Failed to get local file to generate thumbnail for: ' . $file->getPath(), + ['app' => 'core'] + ); + return null; + } try { $audio = new Mp3Info($tmpPath, true); diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index 4a6104930d6f5..ed6a277053ba4 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -10,6 +10,7 @@ use OCP\Files\File; use OCP\Files\FileInfo; use OCP\IImage; +use OCP\Server; use Psr\Log\LoggerInterface; class Movie extends ProviderV2 { @@ -75,6 +76,13 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { foreach ($sizeAttempts as $size) { $absPath = $this->getLocalFile($file, $size); + if ($absPath === false) { + Server::get(LoggerInterface::class)->error( + 'Failed to get local file to generate thumbnail for: ' . $file->getPath(), + ['app' => 'core'] + ); + return null; + } $result = null; if (is_string($absPath)) { diff --git a/lib/private/Preview/Office.php b/lib/private/Preview/Office.php index 20fbef6eb23eb..ffba0211de2be 100644 --- a/lib/private/Preview/Office.php +++ b/lib/private/Preview/Office.php @@ -12,6 +12,7 @@ use OCP\IImage; use OCP\ITempManager; use OCP\Server; +use Psr\Log\LoggerInterface; abstract class Office extends ProviderV2 { /** @@ -33,6 +34,13 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { // The file to generate the preview for. $absPath = $this->getLocalFile($file); + if ($absPath === false) { + Server::get(LoggerInterface::class)->error( + 'Failed to get local file to generate thumbnail for: ' . $file->getPath(), + ['app' => 'core'] + ); + return null; + } // The destination for the LibreOffice user profile. // LibreOffice can rune once per user profile and therefore instance id and file id are included.