Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions lib/private/Preview/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,35 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
if ($result !== null) {
break;
}
Server::get(LoggerInterface::class)->debug(
'Movie preview generation attempt failed'
. ', file=' . $file->getPath()
. ', time=' . $timeStamp
. ', size=' . ($size ?? 'entire file'),
['app' => 'core']
);
}

$this->cleanTmpFiles();

if ($result !== null) {
Server::get(LoggerInterface::class)->debug(
'Movie preview generation attempt success'
. ', file=' . $file->getPath()
. ', time=' . $timeStamp
. ', size=' . ($size ?? 'entire file'),
['app' => 'core']
);
break;
}

}
if ($result === null) {
Server::get(LoggerInterface::class)->error(
'Movie preview generation process failed'
. ', file=' . $file->getPath(),
['app' => 'core']
);
}
return $result;
}
Expand All @@ -128,7 +150,7 @@ private function getSparseFile(File $file, int $size): string|false {
$absPath = Server::get(ITempManager::class)->getTemporaryFile();
if ($absPath === false) {
Server::get(LoggerInterface::class)->error(
'Failed to get sparse file to generate thumbnail: ' . $file->getPath(),
'Failed to get temp file to create sparse file to generate thumbnail: ' . $file->getPath(),
['app' => 'core']
);
fclose($content);
Expand Down Expand Up @@ -214,6 +236,10 @@ private function getSparseFile(File $file, int $size): string|false {
}
fclose($content);
fclose($sparseFile);
Server::get(LoggerInterface::class)->debug(
'Sparse file being utilized for preview generation for ' . $file->getPath(),
['app' => 'core']
);
return $absPath;
}

Expand Down Expand Up @@ -287,21 +313,23 @@ private function generateThumbNail(int $maxX, int $maxY, string $absPath, int $s
$output = $stdout . $stderr;
}

Server::get(LoggerInterface::class)->debug(
'Movie preview generation output'
. ', file=' . $absPath
. ', output=',
['app' => 'core', 'output' => $output]
);

if ($returnCode === 0) {
$image = new \OCP\Image();
$image->loadFromFile($tmpPath);
if ($image->valid()) {
unlink($tmpPath);
$image->scaleDownToFit($maxX, $maxY);

return $image;
}
}

if ($second === 0) {
$logger = Server::get(LoggerInterface::class);
$logger->info('Movie preview generation failed Output: {output}', ['app' => 'core', 'output' => $output]);
}

unlink($tmpPath);
return null;
Expand Down
Loading