Skip to content

Commit

Permalink
Fix logic for clearing pending jobs on interval change
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 27, 2025
1 parent 91d8cb5 commit 50cdee4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions netbox/core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ def clear_events_queue(sender, **kwargs):
#

@receiver(post_save, sender=DataSource)
def enqueue_sync_job(instance, **kwargs):
def enqueue_sync_job(instance, created, **kwargs):
"""
When a DataSource is saved, check its sync_interval and enqueue a sync job if appropriate.
"""
from .jobs import SyncDataSourceJob

if instance.sync_interval:
SyncDataSourceJob.enqueue_once(instance, interval=instance.sync_interval)
else:
elif not created:
# Delete any previously scheduled recurring jobs for this DataSource
SyncDataSourceJob.get_jobs(instance).filter(sync_interval__isnull=False).delete()
SyncDataSourceJob.get_jobs(instance).filter(interval__isnull=False).delete()


@receiver(post_sync)
Expand Down

0 comments on commit 50cdee4

Please sign in to comment.