Skip to content

Commit

Permalink
Fix JsonPath error on dkan:datastore:drop-all (#4098)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-m authored Jan 22, 2024
1 parent 8e7da70 commit 4f0b993
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions modules/datastore/src/Drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ private function createRow($uuid, $item) {
*/
public function drop(string $identifier, array $options = ['keep-local' => FALSE]) {
$local_resource = $options['keep-local'] ? FALSE : TRUE;
$this->datastoreService->drop($identifier, NULL, $local_resource);
$this->logger->notice("Successfully dropped the datastore for resource {$identifier}");
try {
$this->datastoreService->drop($identifier, NULL, $local_resource);
$this->logger->notice('Successfully dropped the datastore for resource ' . $identifier);
}
catch (\InvalidArgumentException $e) {
// We get an invalid argument exception when the datastore does not exist.
// This can be because it was never imported, or because the resource
// is a type that will never be imported, such as a ZIP file.
$this->logger->warning('Unable to drop datastore for ' . $identifier);
}
$this->postImport->removeJobStatus($identifier);
$this->logger->notice("Successfully removed the post import job status for resource {$identifier}");
$this->logger->notice('Successfully removed the post import job status for resource ' . $identifier);
}

/**
Expand All @@ -235,9 +243,11 @@ public function drop(string $identifier, array $options = ['keep-local' => FALSE
* @command dkan:datastore:drop-all
*/
public function dropAll() {
/** @var \RootedData\RootedJsonData $distribution*/
foreach ($this->metastoreService->getAll('distribution') as $distribution) {
$uuid = $distribution->data->{'%Ref:downloadURL'}[0]->data->identifier;
$this->drop($uuid);
if ($uuid = $distribution->get('$[data]["%Ref:downloadURL"][0][data][identifier]') ?? FALSE) {
$this->drop($uuid);
}
}
}

Expand Down

0 comments on commit 4f0b993

Please sign in to comment.