Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/migrations/0018_migrate_swhids.py
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | ): | ||||
) | ) | ||||
continue | continue | ||||
# Starting migration | # Starting migration | ||||
dir_id = obj_dir.object_id | dir_id = obj_dir.object_id | ||||
origin = obj_dir.metadata["origin"] | origin = obj_dir.metadata["origin"] | ||||
check_origin = storage.origin_get({"url": origin}) | check_origin = storage.origin_get([origin])[0] | ||||
if not check_origin: | if not check_origin: | ||||
logger.warning("Deposit id %s: Origin %s not found!", deposit.id, origin) | logger.warning("Deposit id %s: Origin %s not found!", deposit.id, origin) | ||||
continue | continue | ||||
rev_id = obj_rev.object_id | rev_id = obj_rev.object_id | ||||
# Find the snapshot targeting the revision | # Find the snapshot targeting the revision | ||||
snp_id = get_snapshot(storage, origin, rev_id) | snp_id = get_snapshot(storage, origin, rev_id) | ||||
if not snp_id: | if not snp_id: | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | ): | ||||
logger.warning("Deposit id %s: Revision %s not found!", deposit.id, rev_id) | logger.warning("Deposit id %s: Revision %s not found!", deposit.id, rev_id) | ||||
continue | continue | ||||
revision = revisions[0] | revision = revisions[0] | ||||
provider_url = deposit.client.provider_url | provider_url = deposit.client.provider_url | ||||
external_id = deposit.external_id | external_id = deposit.external_id | ||||
origin = resolve_origin(deposit.id, provider_url, external_id) | origin = resolve_origin(deposit.id, provider_url, external_id) | ||||
check_origin = storage.origin_get({"url": origin}) | check_origin = storage.origin_get([origin])[0] | ||||
if not check_origin: | if not check_origin: | ||||
logger.warning("Deposit id %s: Origin %s not found!", deposit.id, origin) | logger.warning("Deposit id %s: Origin %s not found!", deposit.id, origin) | ||||
continue | continue | ||||
dir_id = hash_to_hex(revision["directory"]) | dir_id = hash_to_hex(revision["directory"]) | ||||
# Reference the old values to do some checks later | # Reference the old values to do some checks later | ||||
old_swh_id = deposit.swh_id | old_swh_id = deposit.swh_id | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |