Skip to content

Commit 1dd7894

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
dummy
1 parent cb7ee7c commit 1dd7894

File tree

1 file changed

+23
-25
lines changed
  • stac_fastapi/core/stac_fastapi/core

1 file changed

+23
-25
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,6 @@ async def all_collections(
332332
current_url = str(request.url)
333333
redis_enable = get_bool_env("REDIS_ENABLE", default=False)
334334

335-
redis = None
336-
if redis_enable:
337-
try:
338-
redis = await connect_redis()
339-
logger.info("Redis connection established successfully")
340-
except Exception as e:
341-
redis = None
342-
logger.warning(
343-
f"Redis connection failed, continuing without Redis: {e}"
344-
)
345-
346335
# Convert q to a list if it's a string
347336
q_list = None
348337
if q is not None:
@@ -441,20 +430,29 @@ async def all_collections(
441430
},
442431
]
443432

444-
if redis_enable and redis:
445-
if next_token:
446-
await save_self_link(redis, next_token, current_url)
447-
448-
prev_link = await get_prev_link(redis, token)
449-
if prev_link:
450-
links.insert(
451-
0,
452-
{
453-
"rel": "prev",
454-
"type": "application/json",
455-
"method": "GET",
456-
"href": prev_link,
457-
},
433+
redis = None
434+
if redis_enable:
435+
try:
436+
redis = await connect_redis()
437+
logger.info("Redis connection established successfully")
438+
if redis and next_token:
439+
await save_self_link(redis, next_token, current_url)
440+
441+
prev_link = await get_prev_link(redis, token)
442+
if prev_link:
443+
links.insert(
444+
0,
445+
{
446+
"rel": "prev",
447+
"type": "application/json",
448+
"method": "GET",
449+
"href": prev_link,
450+
},
451+
)
452+
except Exception as e:
453+
redis = None
454+
logger.warning(
455+
f"Redis connection failed, continuing without Redis: {e}"
458456
)
459457

460458
if next_token:

0 commit comments

Comments
 (0)