fix(backups): make datetimes from huey timezone aware
continuous-integration/drone/push Build is failing Details

pull/43/head
Inex Code 2023-07-20 19:39:10 +03:00
parent e0a5ecdd9d
commit c9d20e8efd
2 changed files with 4 additions and 8 deletions

View File

@ -1,7 +1,7 @@
""" """
The tasks module contains the worker tasks that are used to back up and restore The tasks module contains the worker tasks that are used to back up and restore
""" """
from datetime import datetime from datetime import datetime, timezone
from selfprivacy_api.graphql.common_types.backup import RestoreStrategy from selfprivacy_api.graphql.common_types.backup import RestoreStrategy
@ -15,13 +15,8 @@ def validate_datetime(dt: datetime) -> bool:
""" """
Validates that the datetime passed in is timezone-aware. Validates that the datetime passed in is timezone-aware.
""" """
if dt.timetz is None: if dt.tzinfo is None:
raise ValueError( return Backups.is_time_to_backup(dt.replace(tzinfo=timezone.utc))
"""
huey passed in the timezone-unaware time!
Post it in support chat or maybe try uncommenting a line above
"""
)
return Backups.is_time_to_backup(dt) return Backups.is_time_to_backup(dt)

View File

@ -11,4 +11,5 @@ test_mode = os.environ.get("TEST_MODE")
huey = SqliteHuey( huey = SqliteHuey(
HUEY_DATABASE, HUEY_DATABASE,
immediate=test_mode == "true", immediate=test_mode == "true",
utc=True,
) )