diff --git a/lib/Command/Index.php b/lib/Command/Index.php index 2638c6ec0..b7f742dcc 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -123,9 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { // Use static exiftool process \OCA\Memories\Exif::ensureStaticExiftoolProc(); - if (!Service\BinExt::testExiftool()) { // throws - throw new \Exception('exiftool could not be executed or test failed'); - } + Service\BinExt::testExiftool(); // throws // Perform steps based on opts $this->checkClear(); diff --git a/lib/Command/MigrateGoogleTakeout.php b/lib/Command/MigrateGoogleTakeout.php index 96c3c76a9..c284d0631 100644 --- a/lib/Command/MigrateGoogleTakeout.php +++ b/lib/Command/MigrateGoogleTakeout.php @@ -25,6 +25,7 @@ use OCA\Memories\Db\TimelineWrite; use OCA\Memories\Exif; +use OCA\Memories\Service; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -111,6 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Start static exif process Exif::ensureStaticExiftoolProc(); + Service\BinExt::testExiftool(); // throws // Call migration for each user if ($input->getOption('user')) { diff --git a/lib/Cron/IndexJob.php b/lib/Cron/IndexJob.php index caf749020..f0ccda790 100644 --- a/lib/Cron/IndexJob.php +++ b/lib/Cron/IndexJob.php @@ -59,13 +59,23 @@ protected function run($arguments) // Index with static exiftool process // This is sub-optimal: the process may not be required at all. try { + // Start and make sure exiftool is working \OCA\Memories\Exif::ensureStaticExiftoolProc(); + Service\BinExt::testExiftool(); // throws + + // Run the indexer $this->indexAllUsers(); + + // Remove stale index entries $this->service->cleanupStale(); + $this->log('Indexing completed successfully', 'success'); } catch (Service\ProcessClosedException $e) { $this->log('Indexing process stopped before completion. Will continue on next run', 'info'); + } catch (\Exception $e) { + $this->log('Indexing exception: '.$e->getMessage()); } finally { + // Close the static exiftool process \OCA\Memories\Exif::closeStaticExiftoolProc(); } diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index 5a0338dbe..dd92147db 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -91,10 +91,11 @@ public function processFile( } // Get exif data - try { - $exif = Exif::getExifFromFile($file); - } catch (\Exception $e) { - $exif = []; + $exif = Exif::getExifFromFile($file); + + // Check if EXIF is blank, which is probably wrong + if (0 === \count($exif)) { + throw new \Exception('No EXIF data could be read: '.$file->getPath()); } // Hand off if Live Photo video part