Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions wp1/zimfarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ def refresh_zimfarm_token(redis, refresh_token):


def get_zimfarm_token(redis):
data = redis.hgetall(REDIS_AUTH_KEY)
if data is None or data.get("refresh_token") is None:
data = redis.hgetall(REDIS_AUTH_KEY) or {}
data = {
k.decode() if isinstance(k, bytes) else k:
v.decode() if isinstance(v, bytes) else v
for k, v in data.items()
}
Comment thread
audiodude marked this conversation as resolved.
if "refresh_token" not in data:
logger.debug("No saved zimfarm refresh_token, requesting")
return request_zimfarm_token(redis)

Comment on lines +118 to 121
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that Redis bytes keys/values are normalized, the code will start hitting the refresh path, but refresh_zimfarm_token() does not persist the refreshed token/expiry back to Redis. This means expires_time in Redis remains expired and get_zimfarm_token() will call the refresh endpoint on every invocation after expiry. Consider storing the refresh response (and updating expires_time if needed) so subsequent calls can reuse the cached access token.

Copilot uses AI. Check for mistakes.
Expand Down
Loading