Skip to content

Commit

Permalink
places: add force option
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Mar 20, 2024
1 parent 20ec010 commit d1f8551
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/occ-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Usage:
memories:places-setup [options]
Options:
-f, --force Ignore existing setup and re-download planet
-r, --recalculate Only recalculate places for existing files
--transaction-size=50 Reduce this value if your database crashes [default: 50]
```
Expand Down
6 changes: 4 additions & 2 deletions lib/Command/PlacesSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function configure(): void
$this
->setName('memories:places-setup')
->setDescription('Setup reverse geocoding')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Ignore existing setup and re-download planet')
->addOption('recalculate', 'r', InputOption::VALUE_NONE, 'Only recalculate places for existing files')
->addOption('transaction-size', null, InputOption::VALUE_REQUIRED, 'Reduce this value if your database crashes', 50)
;
Expand All @@ -51,7 +52,8 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->output = $output;
$recalculate = $input->getOption('recalculate');
$recalculate = (bool) $input->getOption('recalculate');
$force = (bool) $input->getOption('force');

if (($this->places->txnSize = (int) $input->getOption('transaction-size')) < 1) {
$this->output->writeln('<error>Transaction size must be at least 1</error>');
Expand All @@ -70,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->output->writeln('<info>Database support was detected</info>');

// Check if database is already set up
if ($this->places->geomCount() > 0 && !$recalculate && !$this->warnDownloaded()) {
if (!$recalculate && !$force && $this->places->geomCount() > 0 && !$this->warnDownloaded()) {
return 1;
}

Expand Down

0 comments on commit d1f8551

Please sign in to comment.