diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py --- a/swh/web/common/origin_save.py +++ b/swh/web/common/origin_save.py @@ -19,6 +19,7 @@ from django.db.models import Q, QuerySet from django.utils.html import escape +from swh.scheduler.model import ListedOrigin from swh.scheduler.utils import create_oneshot_task_dict from swh.web import config from swh.web.common import archive @@ -500,13 +501,30 @@ can_create_task = False if can_create_task: - # effectively create the scheduler task + # schedule a oneshot task for saving it right now task_dict = create_oneshot_task_dict( visit_type_tasks[visit_type], **task_kwargs ) - task = scheduler.create_tasks([task_dict])[0] + # then schedule it to recurrently pass on it again later + lister = scheduler.get_or_create_lister( + name="save-code-now", instance_name="save-code-now" + ) + if visit_type == "archives": + listed_origin = ListedOrigin( + lister_id=lister.id, + visit_type="tar", + url=origin_url, + extra_loader_arguments={"artifacts": task_kwargs["artifacts"]}, + ) + else: + listed_origin = ListedOrigin( + lister_id=lister.id, visit_type=visit_type, url=origin_url, + ) + + scheduler.record_listed_origins([listed_origin]) + # pending save request has been accepted if sor: sor.status = SAVE_REQUEST_ACCEPTED