mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 11:56:01 +02:00
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:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user