Test for exiftool before running (fix #6)

pull/37/head
Varun Patil 2022-08-20 02:25:39 +00:00
parent 021ba58adc
commit c0c3423943
2 changed files with 23 additions and 0 deletions

BIN
exiftest.jpg 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -82,6 +82,29 @@ class Index extends Command {
} catch (ContainerExceptionInterface $e) { } catch (ContainerExceptionInterface $e) {
$this->globalService = null; $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 { protected function configure(): void {