add longer source indexing options and a never option, resolves #68

This commit is contained in:
meeb 2021-03-07 13:39:49 +11:00
parent adeafbfcb4
commit 972c184c70
2 changed files with 16 additions and 12 deletions

View File

@ -158,6 +158,9 @@ class Source(models.Model):
EVERY_6_HOURS = 21600, _('Every 6 hours') EVERY_6_HOURS = 21600, _('Every 6 hours')
EVERY_12_HOURS = 43200, _('Every 12 hours') EVERY_12_HOURS = 43200, _('Every 12 hours')
EVERY_24_HOURS = 86400, _('Every 24 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 = models.UUIDField(
_('uuid'), _('uuid'),
@ -218,7 +221,7 @@ class Source(models.Model):
_('index schedule'), _('index schedule'),
choices=IndexSchedule.choices, choices=IndexSchedule.choices,
db_index=True, 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') help_text=_('Schedule of how often to index the source for new media')
) )
download_media = models.BooleanField( download_media = models.BooleanField(

View File

@ -47,6 +47,7 @@ def source_post_save(sender, instance, created, **kwargs):
priority=0, priority=0,
verbose_name=verbose_name.format(instance.name) verbose_name=verbose_name.format(instance.name)
) )
if instance.index_schedule > 0:
delete_task_by_source('sync.tasks.index_source_task', instance.pk) delete_task_by_source('sync.tasks.index_source_task', instance.pk)
log.info(f'Scheduling media indexing for source: {instance.name}') log.info(f'Scheduling media indexing for source: {instance.name}')
verbose_name = _('Index media from source "{}"') verbose_name = _('Index media from source "{}"')