diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 1f2c315..d7b6cf7 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -158,6 +158,9 @@ class Source(models.Model): EVERY_6_HOURS = 21600, _('Every 6 hours') EVERY_12_HOURS = 43200, _('Every 12 hours') EVERY_24_HOURS = 86400, _('Every 24 hours') + EVERY_3_DAYS = 259200, _('Every 3 days') + EVERY_7_DAYS = 604800, _('Every 7 days') + NEVER = 0, _('Never') uuid = models.UUIDField( _('uuid'), @@ -218,7 +221,7 @@ class Source(models.Model): _('index schedule'), choices=IndexSchedule.choices, db_index=True, - default=IndexSchedule.EVERY_6_HOURS, + default=IndexSchedule.EVERY_24_HOURS, help_text=_('Schedule of how often to index the source for new media') ) download_media = models.BooleanField( diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index 1cb1852..acb1300 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -47,17 +47,18 @@ def source_post_save(sender, instance, created, **kwargs): priority=0, verbose_name=verbose_name.format(instance.name) ) - delete_task_by_source('sync.tasks.index_source_task', instance.pk) - log.info(f'Scheduling media indexing for source: {instance.name}') - verbose_name = _('Index media from source "{}"') - index_source_task( - str(instance.pk), - repeat=instance.index_schedule, - queue=str(instance.pk), - priority=5, - verbose_name=verbose_name.format(instance.name), - remove_existing_tasks=True - ) + if instance.index_schedule > 0: + delete_task_by_source('sync.tasks.index_source_task', instance.pk) + log.info(f'Scheduling media indexing for source: {instance.name}') + verbose_name = _('Index media from source "{}"') + index_source_task( + str(instance.pk), + repeat=instance.index_schedule, + queue=str(instance.pk), + priority=5, + verbose_name=verbose_name.format(instance.name), + remove_existing_tasks=True + ) # Trigger the post_save signal for each media item linked to this source as various # flags may need to be recalculated for media in Media.objects.filter(source=instance):