diff --git a/lib/Db/ExifFields.php b/lib/Db/ExifFields.php index e5629f5dd..ec81ca2e2 100644 --- a/lib/Db/ExifFields.php +++ b/lib/Db/ExifFields.php @@ -73,6 +73,7 @@ class ExifFields 'CircleOfConfusion' => true, 'DOF' => true, 'FOV' => true, + 'TagsList' => true, // Currently unused fields 'ExifVersion' => true, diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index 0e38d50fa..8ba098633 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -22,6 +22,7 @@ class TimelineWrite use TimelineWriteMap; use TimelineWriteOrphans; use TimelineWritePlaces; + use TimelineWriteTags; public function __construct( protected IDBConnection $connection, @@ -104,6 +105,10 @@ public function processFile( return Util::transaction(fn () => $this->livePhoto->processVideoPart($file, $exif)); } + if (!empty($exif['TagsList'])){ + Util::transaction(fn () => $this->processTags($file, $exif)); + } + // If control reaches here, it's not a Live Photo video part // But if prevRow exists and dayid is not set, it *was* a live video part // In this case delete that entry (very rare edge case) diff --git a/lib/Db/TimelineWriteTags.php b/lib/Db/TimelineWriteTags.php new file mode 100644 index 000000000..061b03705 --- /dev/null +++ b/lib/Db/TimelineWriteTags.php @@ -0,0 +1,49 @@ +connection->getQueryBuilder(); + $exists = $query->select('id') + ->from('systemtag') + ->where($query->expr()->eq('name', $query->createNamedParameter($tag, IQueryBuilder::PARAM_STR))) + ->executeQuery() + ->fetch(); + + if (!$exists) { + $query = $this->connection->getQueryBuilder(); + $query->insert('systemtag') + ->values([ + 'name' => $query->createNamedParameter($tag, IQueryBuilder::PARAM_STR) + ])->executeStatement(); + $exists = $query->getLastInsertId(); + } + + $query = $this->connection->getQueryBuilder(); + $params = [ + 'systemtagid' => $query->createNamedParameter($exists, IQueryBuilder::PARAM_INT), + 'objectid' => $query->createNamedParameter($file->getId(), IQueryBuilder::PARAM_STR), + 'objecttype' => $query->createNamedParameter('files', IQueryBuilder::PARAM_STR), + ]; + $query->insert('systemtag_object_mapping') + ->values($params)->executeStatement(); + + $this->logger->info("Added $tag to file {$file->getId()}"); + } + } +} +