Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(Places): Use event metadata to compute the place
When using S3 bucket, all the metadata will be computed in a background job. This means that the GPS info won't be in the DB yet, but it will be in the event's metadata.

Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge authored and backportbot[bot] committed Apr 30, 2025
commit 6fa9f4326fa0805080fb1dfec88f4fa4060fd375
5 changes: 0 additions & 5 deletions lib/DB/Place/PlaceMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,4 @@ public function findFileForUserAndPlace(string $userId, string $place, string $f
$rows[0]['meta_value_string']
);
}

public function setPlaceForFile(string $place, int $fileId): void {
$metadata = $this->filesMetadataManager->getMetadata($fileId, true);
$metadata->setString('gps', $place, true);
}
}
2 changes: 1 addition & 1 deletion lib/Listener/PlaceMetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function handle(Event $event): void {

if ($event instanceof MetadataBackgroundEvent) {
$metadata = $event->getMetadata();
$place = $this->mediaPlaceManager->getPlaceForFile($event->getNode()->getId());
$place = $this->mediaPlaceManager->getPlaceForMetadata($metadata);
if ($place !== null) {
$metadata->setString('photos-place', $place, true);
}
Expand Down
15 changes: 5 additions & 10 deletions lib/Service/MediaPlaceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace OCA\Photos\Service;

use OCA\Photos\DB\Place\PlaceMapper;
use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\FilesMetadata\Model\IFilesMetadata;

class MediaPlaceManager {
public function __construct(
Expand All @@ -21,22 +21,17 @@ public function __construct(
}

public function setPlaceForFile(int $fileId): void {
$place = $this->getPlaceForFile($fileId);
$metadata = $this->filesMetadataManager->getMetadata($fileId, true);
$place = $this->getPlaceForMetadata($metadata);

if ($place === null) {
return;
}

$this->placeMapper->setPlaceForFile($place, $fileId);
$metadata->setString('gps', $place, true);
}

public function getPlaceForFile(int $fileId): ?string {
try {
$metadata = $this->filesMetadataManager->getMetadata($fileId, true);
} catch (FilesMetadataNotFoundException) {
return null;
}

public function getPlaceForMetadata(IFilesMetadata $metadata): ?string {
if (!$this->rgcService->arePlacesEnabled() || !$metadata->hasKey('photos-gps')) {
return null;
}
Expand Down
Loading