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
"""
from datetime import datetime
from datetime import datetime, timezone
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.
"""
if dt.timetz is None:
raise ValueError(
"""
huey passed in the timezone-unaware time!
Post it in support chat or maybe try uncommenting a line above
"""
)
if dt.tzinfo is None:
return Backups.is_time_to_backup(dt.replace(tzinfo=timezone.utc))
return Backups.is_time_to_backup(dt)

View File

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