mirror of https://github.com/nextcloud/photos
Merge pull request #2154 from nextcloud/enh/noid/disable-place-setting
add setting 'disable_place'
This commit is contained in:
commit
240184d3a5
|
@ -49,6 +49,10 @@ class UpdateReverseGeocodingFilesCommand extends Command {
|
|||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
try {
|
||||
if (!$this->rgcService->arePlacesEnabled()) {
|
||||
throw new \Exception('Places is disabled');
|
||||
}
|
||||
|
||||
$this->rgcService->buildKDTree(true);
|
||||
} catch (\Exception $ex) {
|
||||
$output->writeln('<error>Failed to update reverse geocoding files</error>');
|
||||
|
|
|
@ -54,8 +54,7 @@ class MediaPlaceManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!$metadata->hasKey('photos-gps')) {
|
||||
if (!$this->rgcService->arePlacesEnabled() || !$metadata->hasKey('photos-gps')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,15 @@ use Hexogen\KDTree\ItemList;
|
|||
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<int, string> */
|
||||
|
@ -46,6 +49,7 @@ class ReverseGeoCoderService {
|
|||
public function __construct(
|
||||
private IAppData $appData,
|
||||
private IClientService $clientService,
|
||||
private IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -80,8 +84,12 @@ class ReverseGeoCoderService {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue