Skip to content

Commit

Permalink
Merge pull request #229 from GeoNode/fixup_delete
Browse files Browse the repository at this point in the history
Fix delete resource
  • Loading branch information
giohappy authored Mar 13, 2024
2 parents b2b038c + c17cd7c commit 1787c78
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions importer/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ def extract_resource_to_publish(
files, action, layer_name, alternate, **kwargs
)

def get_resource(self, resource_name) -> bool:
def get_resource(self, resource_name, return_bool=True) -> bool:
self.get_or_create_store()
_res = self.cat.get_resource(
resource_name, store=self.store, workspace=self.workspace
)
return True if _res else False
if return_bool:
return True if _res else False
return _res

def publish_resources(self, resources: List[str]):
"""
Expand Down Expand Up @@ -87,9 +89,9 @@ def overwrite_resources(self, resources: List[str]):
return result

def delete_resource(self, resource_name):
layer = self.get_resource(resource_name)
if layer and layer.resource:
self.cat.delete(layer.resource, purge="all", recurse=True)
layer = self.get_resource(resource_name, return_bool=False)
if layer:
self.cat.delete(layer, purge="all", recurse=True)
store = self.cat.get_store(
resource_name.split(":")[-1],
workspace=os.getenv(
Expand Down

0 comments on commit 1787c78

Please sign in to comment.