diff --git a/exiftest.jpg b/exiftest.jpg new file mode 100644 index 00000000..7c0411b9 Binary files /dev/null and b/exiftest.jpg differ diff --git a/lib/Command/Index.php b/lib/Command/Index.php index c923fff0..b9de0168 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -82,6 +82,29 @@ class Index extends Command { } catch (ContainerExceptionInterface $e) { $this->globalService = null; } + + // Refuse to run without exiftool + if (!$this->testExif()) { + error_log('FATAL: exiftool could not be found or test failed'); + exit(1); + } + } + + /** Make sure exiftool is available */ + private function testExif() { + $testfile = dirname(__FILE__). '/../../exiftest.jpg'; + $stream = fopen($testfile, 'rb'); + if (!$stream) { + return false; + } + + $exif = \OCA\Memories\Db\Util::getExifFromStream($stream); + fclose($stream); + + if (!$exif || $exif["DateTimeOriginal"] !== "2004:08:31 19:52:58") { + return false; + } + return true; } protected function configure(): void {