mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
fix(backups): make datetimes from huey timezone aware
This commit is contained in:
parent
e0a5ecdd9d
commit
c9d20e8efd
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue