diff --git a/swh/web/admin/deposit.py b/swh/web/admin/deposit.py --- a/swh/web/admin/deposit.py +++ b/swh/web/admin/deposit.py @@ -94,16 +94,17 @@ elif raw_metadata and d["type"] == "code": provenance = parse_swh_deposit_origin(raw_metadata) - if not provenance and d["origin_url"]: - provenance = d["origin_url"] + if d["type"] == "code" and not provenance: + if d["origin_url"]: + provenance = d["origin_url"] - # Finally, if still not found, we determine uri using the swhid - if not provenance and d["swhid_context"]: - # Trying to compute the origin as we did before in the js - from swh.model.swhids import QualifiedSWHID + # Finally, if still not found, we determine uri using the swhid + if not provenance and d["swhid_context"]: + # Trying to compute the origin as we did before in the js + from swh.model.swhids import QualifiedSWHID - swhid = QualifiedSWHID.from_string(d["swhid_context"]) - provenance = swhid.origin + swhid = QualifiedSWHID.from_string(d["swhid_context"]) + provenance = swhid.origin data_dict["uri"] = provenance # could be None