Page MenuHomeSoftware Heritage

D2977.diff
No OneTemporary

D2977.diff

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

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

Event Timeline