Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123104
D2887.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2887.diff
View Options
diff --git a/swh/loader/core/loader.py b/swh/loader/core/loader.py
--- a/swh/loader/core/loader.py
+++ b/swh/loader/core/loader.py
@@ -14,7 +14,8 @@
from swh.core import config
from swh.model.model import (
BaseContent, Content, SkippedContent, Directory, Origin, Revision,
- Release, Snapshot)
+ Release, Sha1Git, Snapshot
+)
from swh.storage import get_storage
@@ -254,6 +255,10 @@
"""
return 'full'
+ def get_snapshot_id(self) -> Optional[Sha1Git]:
+ """Get the snapshot id that needs to be loaded"""
+ raise NotImplementedError
+
def pre_cleanup(self) -> None:
"""As a first step, will try and check for dangling data to cleanup.
This should do its best to avoid raising issues.
@@ -301,7 +306,8 @@
self.store_metadata()
self.storage.origin_visit_update(
- self.origin.url, self.visit.visit, self.visit_status()
+ self.origin.url, self.visit.visit, self.visit_status(),
+ snapshot=self.get_snapshot_id()
)
self.post_load()
except Exception:
@@ -311,7 +317,8 @@
'swh_task_kwargs': kwargs,
})
self.storage.origin_visit_update(
- self.origin.url, self.visit.visit, 'partial'
+ self.origin.url, self.visit.visit, 'partial',
+ snapshot=self.get_snapshot_id()
)
self.post_load(success=False)
return {'status': 'failed'}
@@ -374,6 +381,10 @@
"""Get the snapshot that needs to be loaded"""
raise NotImplementedError
+ def get_snapshot_id(self) -> Optional[Sha1Git]:
+ snapshot = self.get_snapshot()
+ return snapshot.id if snapshot else None
+
def eventful(self) -> bool:
"""Whether the load was eventful"""
raise NotImplementedError
diff --git a/swh/loader/core/tests/test_loader.py b/swh/loader/core/tests/test_loader.py
--- a/swh/loader/core/tests/test_loader.py
+++ b/swh/loader/core/tests/test_loader.py
@@ -26,6 +26,9 @@
def store_data(self):
pass
+ def get_snapshot_id(self):
+ return None
+
def prepare_origin_visit(self, *args, **kwargs):
origin = Origin(url='some-url')
self.origin = origin
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 17, 9:38 PM (2 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222691
Attached To
D2887: core.loader: Allow core loader to update origin_visit in one call
Event Timeline
Log In to Comment