fix: link old
This commit is contained in:
@@ -18,11 +18,19 @@ class PhotoPreview
|
||||
*/
|
||||
public function payload(string $absPath, string $deviceKey, string $sha256): array
|
||||
{
|
||||
$mime = @mime_content_type($absPath) ?: 'application/octet-stream';
|
||||
$raw = (string) file_get_contents($absPath);
|
||||
if ($raw === '' || ! $this->isHeic($absPath, $mime, $raw)) {
|
||||
if (! is_file($absPath) || ! is_readable($absPath)) {
|
||||
return [
|
||||
'bytes' => $raw,
|
||||
'bytes' => '',
|
||||
'mime' => 'application/octet-stream',
|
||||
'converted' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$mime = @mime_content_type($absPath) ?: 'application/octet-stream';
|
||||
$head = (string) @file_get_contents($absPath, false, null, 0, 64);
|
||||
if ($head === '' || ! $this->isHeic($absPath, $mime, $head)) {
|
||||
return [
|
||||
'bytes' => (string) @file_get_contents($absPath),
|
||||
'mime' => $mime,
|
||||
'converted' => false,
|
||||
];
|
||||
@@ -49,7 +57,7 @@ class PhotoPreview
|
||||
]);
|
||||
|
||||
return [
|
||||
'bytes' => $raw,
|
||||
'bytes' => (string) @file_get_contents($absPath),
|
||||
'mime' => $mime,
|
||||
'converted' => false,
|
||||
];
|
||||
@@ -142,7 +150,16 @@ class PhotoPreview
|
||||
}
|
||||
|
||||
foreach ($this->convertCommands($src, $dst) as $cmd) {
|
||||
$result = Process::timeout(45)->run($cmd);
|
||||
try {
|
||||
$result = Process::timeout(45)->run($cmd);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('heic preview convert threw', [
|
||||
'path' => $absPath,
|
||||
'cmd' => $cmd[0] ?? '',
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
if (! $result->successful() || ! is_file($dst) || filesize($dst) < 3) {
|
||||
continue;
|
||||
}
|
||||
@@ -152,6 +169,13 @@ class PhotoPreview
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('heic preview convert threw', [
|
||||
'path' => $absPath,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return null;
|
||||
} finally {
|
||||
if (is_string($src) && is_file($src)) {
|
||||
|
||||
Reference in New Issue
Block a user