Skip to content

Commit cc96d23

Browse files
committed
prep update collection
1 parent ad6f393 commit cc96d23

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,9 @@ def create_collection(self, collection: stac_types.Collection):
283283
document=collection,
284284
)
285285

286+
def prep_update_collection(self, collection_id: str):
287+
try:
288+
_ = self.client.get(index=COLLECTIONS_INDEX, id=collection_id)
289+
except elasticsearch.exceptions.NotFoundError:
290+
raise NotFoundError(f"Collection {collection_id} not found")
291+

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ def update_collection(
101101
) -> stac_types.Collection:
102102
"""Update collection."""
103103
base_url = str(kwargs["request"].base_url)
104-
try:
105-
_ = self.client.get(index=COLLECTIONS_INDEX, id=collection["id"])
106-
except elasticsearch.exceptions.NotFoundError:
107-
raise NotFoundError(f"Collection {collection['id']} not found")
104+
105+
self.database.prep_update_collection(collection_id=collection["id"])
108106
self.delete_collection(collection["id"])
109107
self.create_collection(collection, **kwargs)
110108

0 commit comments

Comments
 (0)