Skip to content

Commit 8dddc8c

Browse files
committed
Fix a regression when reopening a persisted Proxy with mode='r'
1 parent 17f12c6 commit 8dddc8c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/blosc2/schunk.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,13 +1635,17 @@ def _set_default_dparams(kwargs):
16351635
def process_opened_object(res):
16361636
meta = getattr(res, "schunk", res).meta
16371637
if "proxy-source" in meta:
1638+
proxy_cache = res
1639+
cache_schunk = getattr(res, "schunk", res)
1640+
if getattr(cache_schunk, "urlpath", None) is not None and getattr(cache_schunk, "mode", None) == "r":
1641+
proxy_cache = blosc2_ext.open(cache_schunk.urlpath, "a", 0)
16381642
proxy_src = meta["proxy-source"]
16391643
if proxy_src["local_abspath"] is not None:
16401644
src = blosc2.open(proxy_src["local_abspath"], mode="a")
1641-
return blosc2.Proxy(src, _cache=res)
1645+
return blosc2.Proxy(src, _cache=proxy_cache)
16421646
elif proxy_src["urlpath"] is not None:
16431647
src = blosc2.C2Array(proxy_src["urlpath"][0], proxy_src["urlpath"][1], proxy_src["urlpath"][2])
1644-
return blosc2.Proxy(src, _cache=res)
1648+
return blosc2.Proxy(src, _cache=proxy_cache)
16451649
elif not proxy_src["caterva2_env"]:
16461650
raise RuntimeError("Could not find the source when opening a Proxy")
16471651

0 commit comments

Comments
 (0)