Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066466
D2977.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
D2977.diff
View Options
diff --git a/swh/storage/storage.py b/swh/storage/storage.py
--- a/swh/storage/storage.py
+++ b/swh/storage/storage.py
@@ -188,7 +188,8 @@
@process_metrics
def content_add(
self, content: Iterable[Content]) -> Dict:
- contents = [attr.evolve(c, ctime=now()) for c in content]
+ ctime = now()
+ contents = [attr.evolve(c, ctime=ctime) for c in content]
objstorage_summary = self.objstorage.content_add(contents)
@@ -398,7 +399,8 @@
@db_transaction()
def skipped_content_add(self, content: Iterable[SkippedContent],
db=None, cur=None) -> Dict:
- content = [attr.evolve(c, ctime=now()) for c in content]
+ ctime = now()
+ content = [attr.evolve(c, ctime=ctime) for c in content]
missing_contents = self.skipped_content_missing(
(c.to_dict() for c in content),
diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py
--- a/swh/storage/tests/test_storage.py
+++ b/swh/storage/tests/test_storage.py
@@ -330,6 +330,12 @@
Content.from_dict(cont1b).hashes()
]
+ def test_content_add_duplicate(self, swh_storage):
+ swh_storage.content_add([data.cont, data.cont])
+
+ assert list(swh_storage.content_get([data.cont['sha1']])) == \
+ [{'sha1': data.cont['sha1'], 'data': data.cont['data']}]
+
def test_content_update(self, swh_storage):
if hasattr(swh_storage, 'storage'):
swh_storage.journal_writer.journal = None # TODO, not supported
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 10:51 AM (12 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221590
Attached To
D2977: Prevent erroneous HashCollisions by using the same ctime for all rows.
Event Timeline
Log In to Comment