Fix timezone comparison in GitHub backup scheduler

The scheduler compared timezone-aware datetime.now(UTC) with naive
datetimes from the SQLite database, causing "can't compare offset-naive
and offset-aware datetimes" error.

Fixed by adding UTC timezone to naive datetimes before comparison.
This commit is contained in:
maziggy
2026-01-27 15:21:32 +01:00
parent 84fe13dd07
commit 14e8e512f2
+5 -1
View File
@@ -87,7 +87,11 @@ class GitHubBackupService:
now = datetime.now(UTC)
for config in configs:
if config.next_scheduled_run and config.next_scheduled_run <= now:
# Handle both naive (from DB) and aware datetimes
next_run = config.next_scheduled_run
if next_run and next_run.tzinfo is None:
next_run = next_run.replace(tzinfo=UTC)
if next_run and next_run <= now:
logger.info(f"Running scheduled backup for config {config.id}")
await self.run_backup(config.id, trigger="scheduled")