diff --git a/lib/Command/UpdateReverseGeocodingFilesCommand.php b/lib/Command/UpdateReverseGeocodingFilesCommand.php
index 3d6250f3e..ac6c39273 100644
--- a/lib/Command/UpdateReverseGeocodingFilesCommand.php
+++ b/lib/Command/UpdateReverseGeocodingFilesCommand.php
@@ -49,6 +49,10 @@ protected function configure(): void {
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
+ if (!$this->rgcService->arePlacesEnabled()) {
+ throw new \Exception('Place is disabled');
+ }
+
$this->rgcService->buildKDTree(true);
} catch (\Exception $ex) {
$output->writeln('Failed to update reverse geocoding files');
diff --git a/lib/Service/MediaPlaceManager.php b/lib/Service/MediaPlaceManager.php
index eaf9a2252..67e5c9002 100644
--- a/lib/Service/MediaPlaceManager.php
+++ b/lib/Service/MediaPlaceManager.php
@@ -54,8 +54,7 @@ public function getPlaceForFile(int $fileId): ?string {
return null;
}
-
- if (!$metadata->hasKey('photos-gps')) {
+ if (!$this->rgcService->arePlacesEnabled() || !$metadata->hasKey('photos-gps')) {
return null;
}
diff --git a/lib/Service/ReverseGeoCoderService.php b/lib/Service/ReverseGeoCoderService.php
index 10acfbd4b..23b21e9ca 100644
--- a/lib/Service/ReverseGeoCoderService.php
+++ b/lib/Service/ReverseGeoCoderService.php
@@ -32,12 +32,15 @@
use Hexogen\KDTree\KDTree;
use Hexogen\KDTree\NearestSearch;
use Hexogen\KDTree\Point;
+use OCA\Photos\AppInfo\Application;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
class ReverseGeoCoderService {
+ public const CONFIG_DISABLE_PLACES = 'disable_places';
private ?ISimpleFolder $geoNameFolderCache = null;
private ?NearestSearch $fsSearcher = null;
/** @var array */
@@ -46,6 +49,7 @@ class ReverseGeoCoderService {
public function __construct(
private IAppData $appData,
private IClientService $clientService,
+ private IConfig $config,
) {
}
@@ -80,8 +84,12 @@ private function getPlaceNameForPlaceId(int $placeId): string {
return $this->citiesMapping[$placeId];
}
+ public function arePlacesEnabled(): bool {
+ return ($this->config->getAppValue(Application::APP_ID, self::CONFIG_DISABLE_PLACES, '0') !== '1');
+ }
+
private function downloadCities1000(bool $force = false): void {
- if ($this->geoNameFolder()->fileExists('cities1000.csv') && !$force) {
+ if (!$this->arePlacesEnabled() || ($this->geoNameFolder()->fileExists('cities1000.csv') && !$force)) {
return;
}