diff --git a/swh/provenance/cli.py b/swh/provenance/cli.py --- a/swh/provenance/cli.py +++ b/swh/provenance/cli.py @@ -181,7 +181,7 @@ def origin_from_journal(ctx: click.core.Context): from swh.journal.client import get_journal_client - from .journal_client import process_journal_objects + from .journal_client import process_journal_origins provenance = ctx.obj["provenance"] archive = ctx.obj["archive"] @@ -189,7 +189,7 @@ journal_cfg = ctx.obj["config"].get("journal_client", {}) worker_fn = partial( - process_journal_objects, + process_journal_origins, archive=archive, provenance=provenance, ) diff --git a/swh/provenance/journal_client.py b/swh/provenance/journal_client.py --- a/swh/provenance/journal_client.py +++ b/swh/provenance/journal_client.py @@ -9,8 +9,8 @@ from swh.storage.interface import StorageInterface -def process_journal_objects( - messages, *, provenance: ProvenanceInterface, archive: StorageInterface +def process_journal_origins( + messages, *, provenance: ProvenanceInterface, archive: StorageInterface, **cfg ) -> None: """Worker function for `JournalClient.process(worker_fn)`.""" assert set(messages) == {"origin_visit_status"}, set(messages) @@ -19,5 +19,6 @@ for visit in messages["origin_visit_status"] if visit["snapshot"] is not None ] - with provenance: - origin_add(provenance, archive, origin_entries) + if origin_entries: + with provenance: + origin_add(provenance, archive, origin_entries, **cfg)