diff --git a/lib/private/Preview/Image.php b/lib/private/Preview/Image.php index 69841f079296e..c6090a5b57c5b 100644 --- a/lib/private/Preview/Image.php +++ b/lib/private/Preview/Image.php @@ -9,6 +9,7 @@ use OCP\Files\File; use OCP\IImage; +use Psr\Log\LoggerInterface; abstract class Image extends ProviderV2 { /** @@ -25,6 +26,13 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $image = new \OCP\Image(); $fileName = $this->getLocalFile($file); + if ($fileName === false) { + \OC::$server->get(LoggerInterface::class)->error( + 'Failed to get 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..847afcc2a2f51 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -9,6 +9,7 @@ use OCP\Files\File; use OCP\IImage; +use Psr\Log\LoggerInterface; use wapmorgan\Mp3Info\Mp3Info; use function OCP\Log\logger; @@ -25,7 +26,14 @@ public function getMimeType(): string { */ 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(), + ['app' => 'core'] + ); + return null; + } + try { $audio = new Mp3Info($tmpPath, true); /** @var string|null|false $picture */ diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index 4a6104930d6f5..b4e516183fba8 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -75,6 +75,13 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { foreach ($sizeAttempts as $size) { $absPath = $this->getLocalFile($file, $size); + if ($absPath === false) { + \OC::$server->get(LoggerInterface::class)->error( + 'Failed to get 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..01bdd01ee7d17 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) { + \OC::$server->get(LoggerInterface::class)->error( + 'Failed to get 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.