Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android client gets internal server error logging into timezone-aware server 8.0.3 #2431

Open
jimays opened this issue Mar 1, 2021 · 0 comments

Comments

@jimays
Copy link

jimays commented Mar 1, 2021

Android client gets Internal Server Error logging into 8.0.3 server that has been made timezone aware by setting TIMEZONE and USE_TZ=True in seahub_settings.py.

Traceback in seahub.log ends with:

File "/opt/seafile/seafile-server-8.0.3/seahub/seahub/api2/authentication.py", line 130, in authenticate_v2
if not within_time_range(token.last_accessed, datetime.datetime.now(), 10 * 60):
File "/opt/seafile/seafile-server-8.0.3/seahub/seahub/utils/init.py", line 1335, in within_time_range
delta = d2 - d1 if d2 > d1 else d1 - d2
TypeError: can't compare offset-naive and offset-aware datetimes
2021-03-01 07:32:24,435 [ERROR] django.request:228 log_response Internal Server Error: /seafile/api2/account/inf
o/

I fixed this issue with a patch as I posted in https://forum.seafile.com/t/seafile-client-doesnt-connect-to-server/11983/3

vi /opt/seafile/seafile-server-8.0.3/seahub/seahub/api2/authentication.py # near line 130, fix mobile login
        # 13.0.8.5.12-t6 jimays token.last_accessed is timezone-aware, so must be compared with such
        # gratitude stackoverflow questions/4530069/how-do-i-get-a-value-of-datetime-today-in-py
thon-that-is-timezone-aware/25421145
        # gratitude stackoverflow questions/5802108/how-to-check-if-a-datetime-object-is-localiz
ed-with-pytz

        # if not within_time_range(token.last_accessed, datetime.datetime.now(), 10 * 60):

        import pytz
        if not within_time_range(token.last_accessed, datetime.datetime.now() if (token.last_accessed.tzinfo is None or token.last_accessed.tzinfo.utcoffset(token.last_accessed) is None) else datetime.datetime.utcnow().replace(tzinfo=pytz.utc), 10 * 60):
@jimays jimays changed the title Androd client gets internal server error logging into timezone-aware server 8.0.3 Android client gets internal server error logging into timezone-aware server 8.0.3 Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant