Skip to content

Commit f07af6e

Browse files
committed
Add more error handling to exif
1 parent 79f9e27 commit f07af6e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Exif.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,22 @@ public static function setExif(string $path, array $data): void
351351
]);
352352

353353
try {
354-
$stdout = Util::execSafe($cmd, self::EXIFTOOL_TIMEOUT, $raw) ?? 'error: cmd fail';
354+
$output = Util::execSafe2($cmd, self::EXIFTOOL_TIMEOUT, $raw, true, true);
355+
$stdout = $output[0];
356+
$stderr = $output[1];
355357
} catch (\Exception $ex) {
356358
error_log("Timeout reading from exiftool: [{$path}]");
357359

358360
throw $ex;
359361
}
360362

361-
if (str_contains($stdout, 'error')) {
363+
if (null !== $stderr && str_contains($stderr, 'Error')) {
364+
error_log("Exiftool error: {$stderr}");
365+
366+
throw new \Exception('Could not set exif data: '.$stderr);
367+
}
368+
if (null === $stdout || str_contains($stdout, 'Error')) {
369+
$stdout = $stdout ?? $stderr ?? 'Error: Unknown cmd fail';
362370
error_log("Exiftool error: {$stdout}");
363371

364372
throw new \Exception('Could not set exif data: '.$stdout);

0 commit comments

Comments
 (0)