Fixes for ruff check in reset-tasks.py

This commit is contained in:
tcely 2025-05-18 03:12:12 -04:00 committed by GitHub
parent c69cd7f582
commit 2ece2e7f38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,14 +1,12 @@
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError # noqa
from django.db.transaction import atomic from django.db.transaction import atomic
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from background_task.models import Task from background_task.models import Task
from common.logger import log
from sync.models import Source from sync.models import Source
from sync.tasks import index_source_task, check_source_directory_exists from sync.tasks import index_source_task, check_source_directory_exists
from common.logger import log
class Command(BaseCommand): class Command(BaseCommand):
help = 'Resets all tasks' help = 'Resets all tasks'
@ -31,10 +29,10 @@ class Command(BaseCommand):
index_source_task( index_source_task(
str(source.pk), str(source.pk),
repeat=source.index_schedule, repeat=source.index_schedule,
schedule=source.index_schedule,
verbose_name=verbose_name.format(source.name), verbose_name=verbose_name.format(source.name),
) )
with atomic(durable=True):
for source in Source.objects.all():
# This also chains down to call each Media objects .save() as well # This also chains down to call each Media objects .save() as well
source.save() source.save()
log.info('Done') log.info('Done')