@@ -1824,18 +1824,40 @@ def open(
18241824 if isinstance (urlpath , pathlib .PurePath ):
18251825 urlpath = str (urlpath )
18261826
1827- urlpath = _resolve_store_alias (urlpath )
1827+ # Keep explicit store paths on the direct dispatch path. For regular
1828+ # Blosc containers, try the standard open first and only fall back to the
1829+ # more expensive store probing when that fails.
1830+ if urlpath .endswith ((".b2d" , ".b2z" , ".b2e" )):
1831+ special = _open_special_store (urlpath , mode , offset , ** kwargs )
1832+ if special is not None :
1833+ if isinstance (special , blosc2 .TreeStore ):
1834+ return _open_treestore_root_object (special , urlpath , mode )
1835+ return special
1836+
1837+ regular_exc = None
1838+ if os .path .exists (urlpath ):
1839+ _set_default_dparams (kwargs )
1840+ try :
1841+ res = blosc2_ext .open (urlpath , mode , offset , ** kwargs )
1842+ except Exception as exc :
1843+ regular_exc = exc
1844+ else :
1845+ return process_opened_object (res )
18281846
1829- special = _open_special_store (urlpath , mode , offset , ** kwargs )
1847+ resolved_urlpath = _resolve_store_alias (urlpath )
1848+ special_path = resolved_urlpath if resolved_urlpath != urlpath or not os .path .exists (urlpath ) else urlpath
1849+ special = _open_special_store (special_path , mode , offset , ** kwargs )
18301850 if special is not None :
18311851 if isinstance (special , blosc2 .TreeStore ):
1832- return _open_treestore_root_object (special , urlpath , mode )
1852+ return _open_treestore_root_object (special , special_path , mode )
18331853 return special
18341854
1835- if not os .path .exists (urlpath ):
1836- raise FileNotFoundError (f"No such file or directory: { urlpath } " )
1855+ if regular_exc is not None :
1856+ raise regular_exc
1857+ if not os .path .exists (special_path ):
1858+ raise FileNotFoundError (f"No such file or directory: { special_path } " )
18371859
18381860 _set_default_dparams (kwargs )
1839- res = blosc2_ext .open (urlpath , mode , offset , ** kwargs )
1861+ res = blosc2_ext .open (special_path , mode , offset , ** kwargs )
18401862
18411863 return process_opened_object (res )
0 commit comments