Skip to content

Commit

Permalink
index: prevent blank exif indexing
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Sep 29, 2023
1 parent d773f36 commit 697fc45
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/Command/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions lib/Command/MigrateGoogleTakeout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')) {
Expand Down
10 changes: 10 additions & 0 deletions lib/Cron/IndexJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
9 changes: 5 additions & 4 deletions lib/Db/TimelineWrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 697fc45

Please sign in to comment.