Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7343103
D5634.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D5634.diff
View Options
diff --git a/swh/storage/fixer.py b/swh/storage/fixer.py
--- a/swh/storage/fixer.py
+++ b/swh/storage/fixer.py
@@ -9,6 +9,7 @@
from typing import Any, Dict, List, Optional
from swh.model.identifiers import normalize_timestamp
+from swh.model.model import Origin
logger = logging.getLogger(__name__)
@@ -290,6 +291,27 @@
return visit
+def _fix_raw_extrinsic_metadata(obj_dict: Dict) -> Dict:
+ """Fix legacy RawExtrinsicMetadata with type which is no longer part of the model.
+
+ >>> _fix_raw_extrinsic_metadata({
+ ... 'type': 'directory',
+ ... 'target': 'swh:1:dir:460a586d1c95d120811eaadb398d534e019b5243',
+ ... })
+ {'target': 'swh:1:dir:460a586d1c95d120811eaadb398d534e019b5243'}
+ >>> _fix_raw_extrinsic_metadata({
+ ... 'type': 'origin',
+ ... 'target': 'https://inria.halpreprod.archives-ouvertes.fr/hal-01667309',
+ ... })
+ {'target': 'swh:1:ori:155291d5b9ada4570672510509f93fcfd9809882'}
+
+ """
+ o = obj_dict.copy()
+ if o.pop("type", None) == "origin":
+ o["target"] = str(Origin(o["target"]).swhid())
+ return o
+
+
def fix_objects(object_type: str, objects: List[Dict]) -> List[Dict]:
"""
Fix legacy objects from the journal to bring them up to date with the
@@ -304,5 +326,7 @@
return [_fix_origin(v) for v in objects]
elif object_type == "origin_visit":
return [_fix_origin_visit(v) for v in objects]
+ elif object_type == "raw_extrinsic_metadata":
+ return [_fix_raw_extrinsic_metadata(v) for v in objects]
else:
return objects
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 17 2025, 7:24 PM (7 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223762
Attached To
D5634: Add a fixer for ExtrinsicRawMetadata
Event Timeline
Log In to Comment