From d02ce0b21d3bf33c7302a7c060f4ede7cddae251 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 9 Sep 2022 00:36:53 -0700 Subject: [PATCH] Improve Exif test logs --- lib/Command/Index.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/Command/Index.php b/lib/Command/Index.php index 7cdfffbd..09e0cc69 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -95,13 +95,27 @@ class Index extends Command { $testfile = dirname(__FILE__). '/../../exiftest.jpg'; $stream = fopen($testfile, 'rb'); if (!$stream) { + error_log("Couldn't open Exif test file $testfile"); return false; } - $exif = \OCA\Memories\Exif::getExifFromStream($stream); - fclose($stream); + $exif = null; + try { + $exif = \OCA\Memories\Exif::getExifFromStream($stream); + } catch (\Exception $e) { + error_log("Couldn't read Exif data from test file: " . $e->getMessage()); + return false; + } finally { + fclose($stream); + } - if (!$exif || $exif["DateTimeOriginal"] !== "2004:08:31 19:52:58") { + if (!$exif) { + error_log("Got blank Exif data from test file"); + return false; + } + + if ($exif["DateTimeOriginal"] !== "2004:08:31 19:52:58") { + error_log("Got unexpected Exif data from test file"); return false; } return true;