storage: add support for ignore_errors to get_on_index with cache (#89064)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
26ca816b59
commit
55897c68b3
|
@ -343,3 +343,7 @@ def test_publisher_cache():
|
|||
|
||||
assert Foobar2.cached_get('1') is not test
|
||||
assert Foobar2.cached_get('1') is Foobar2.get_on_index('unique-value', 'unique_value', use_cache=True)
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
Foobar2.get_on_index('unique-value', 'invalid', use_cache=True)
|
||||
assert Foobar2.get_on_index('unique-value', 'invalid', use_cache=True, ignore_errors=True) is None
|
||||
|
|
|
@ -540,6 +540,8 @@ class StorableObject:
|
|||
try:
|
||||
object_id = os.readlink(filename).split('/')[-1]
|
||||
except FileNotFoundError:
|
||||
if ignore_errors:
|
||||
return None
|
||||
raise KeyError(id)
|
||||
return cls.cached_get(object_id, ignore_errors=ignore_errors, ignore_migration=ignore_migration)
|
||||
return cls.get_filename(filename, ignore_errors=ignore_errors, ignore_migration=ignore_migration)
|
||||
|
|
Loading…
Reference in New Issue