Page MenuHomeSoftware Heritage

D6315.id22932.diff
No OneTemporary

D6315.id22932.diff

diff --git a/swh/storage/postgresql/storage.py b/swh/storage/postgresql/storage.py
--- a/swh/storage/postgresql/storage.py
+++ b/swh/storage/postgresql/storage.py
@@ -914,9 +914,13 @@
db: Db,
cur=None,
) -> Optional[PartialBranches]:
+
if snapshot_id == EMPTY_SNAPSHOT_ID:
return PartialBranches(id=snapshot_id, branches={}, next_branch=None,)
+ if list(self.snapshot_missing([snapshot_id])):
+ return None
+
branches = {}
next_branch = None
diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py
--- a/swh/storage/tests/storage_tests.py
+++ b/swh/storage/tests/storage_tests.py
@@ -22,6 +22,7 @@
from swh.model import from_disk
from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes
from swh.model.hypothesis_strategies import objects
+from swh.model.hypothesis_strategies import snapshots as unknown_snapshot
from swh.model.identifiers import CoreSWHID, ObjectType
from swh.model.model import (
Content,
@@ -3656,6 +3657,12 @@
assert partial_branches is not None
assert partial_branches["branches"] == {}
+ @settings(suppress_health_check=function_scoped_fixture_check,)
+ @given(unknown_snapshot(min_size=1))
+ def test_snapshot_get_unknown_snapshot(self, swh_storage, unknown_snapshot):
+ assert swh_storage.snapshot_get(unknown_snapshot.id) is None
+ assert swh_storage.snapshot_get_branches(unknown_snapshot.id) is None
+
def test_snapshot_add_get(self, swh_storage, sample_data):
snapshot = sample_data.snapshot
origin = sample_data.origin

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 12:19 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3228597

Event Timeline