@@ -84,6 +84,7 @@ class FilesPlugin extends ServerPlugin {
8484 public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count ' ;
8585 public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count ' ;
8686 public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size ' ;
87+ public const FILE_METADATA_GPS = '{http://nextcloud.org/ns}file-metadata-gps ' ;
8788
8889 /** Reference to main server object */
8990 private ?Server $ server = null ;
@@ -438,6 +439,27 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
438439
439440 return $ sizeMetadata ->getValue ();
440441 });
442+
443+ $ propFind ->handle (self ::FILE_METADATA_GPS , function () use ($ node ) {
444+ if (!str_starts_with ($ node ->getFileInfo ()->getMimetype (), 'image ' )) {
445+ return json_encode ((object )[], JSON_THROW_ON_ERROR );
446+ }
447+
448+ if ($ node ->hasMetadata ('gps ' )) {
449+ $ gpsMetadata = $ node ->getMetadata ('gps ' );
450+ } else {
451+ // This code path should not be called since we try to preload
452+ // the metadata when loading the folder or the search results
453+ // in one go
454+ $ metadataManager = \OC ::$ server ->get (IMetadataManager::class);
455+ $ gpsMetadata = $ metadataManager ->fetchMetadataFor ('gps ' , [$ node ->getId ()])[$ node ->getId ()];
456+
457+ // TODO would be nice to display this in the profiler...
458+ \OC ::$ server ->get (LoggerInterface::class)->debug ('Inefficient fetching of metadata ' );
459+ }
460+
461+ return $ gpsMetadata ->getValue ();
462+ });
441463 }
442464 }
443465
0 commit comments