Skip to content

Commit

Permalink
Remove try statement from middleware
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Apr 24, 2024
1 parent 6418dfd commit 9eaf786
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@ async def upgrade_middleware(request: web.BaseRequest, handler: Coroutine):
"""Blocking middleware for upgrades."""
context: AdminRequestContext = request["context"]

is_upgrading = []
async with context.profile.session() as session:
storage = session.inject(BaseStorage)
try:
await storage.find_record(RECORD_TYPE_ACAPY_UPGRADING, tag_query={})
except StorageNotFoundError:
return await handler(request)
is_upgrading = await storage.find_all_records(RECORD_TYPE_ACAPY_UPGRADING)

if not is_upgrading:
return await handler(request)

raise web.HTTPServiceUnavailable(reason="Upgrade in progress")

Expand Down

0 comments on commit 9eaf786

Please sign in to comment.