From 501e80f54fc7df72903189768052a8085a3b23ef Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Wed, 9 Oct 2024 14:55:45 -0700 Subject: [PATCH] Work around ReferenceStore uri having an empty `uri` field (what?) --- src/referencestore.jl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/referencestore.jl b/src/referencestore.jl index 05b95e6..92cd4ee 100644 --- a/src/referencestore.jl +++ b/src/referencestore.jl @@ -196,22 +196,27 @@ function Zarr.storefromstring(::Type{<: ReferenceStore}, url, _) # Extract the parameters, and reformat the URI params = URIs.queryparams(uri) uri = URIs.URI(uri; query = URIs.absent) + provided_path = URIs.uristring(uri) # If the URI's scheme is empty, we're resolving a local file path. # Note that we always use PosixPaths here, because the Zarr spec mandates that # all path separators be forward slashes. Kerchunk also mandates this. file_path = if isempty(uri.scheme) - if isabspath(uri.uri) - FilePathsBase.PosixPath(uri.uri) - elseif ispath(uri.uri) - FilePathsBase.PosixPath(joinpath(pwd(), uri.uri)) + if ispath(provided_path) + if isabspath(provided_path) + FilePathsBase.PosixPath(provided_path) + else + FilePathsBase.PosixPath(joinpath(pwd(), provided_path)) + end else - error("Invalid path, presumed local but not resolvable as absolute or relative path: $(uri)") + error("Invalid path, presumed local but not resolvable as absolute or relative path: `$(uri)`") end elseif uri.scheme == "file" # Otherwise, we check the protocol and create the appropriate path type. FilePathsBase.Path(uri.path) elseif uri.scheme == "s3" - AWSS3.S3Path(uri.uri) + AWSS3.S3Path(provided_path) + else + FilePathsBase.@p_str uri.path end # TODO: add more protocols, like HTTP, Google Cloud, Azure, etc. rs = ReferenceStore(file_path) @@ -222,7 +227,7 @@ function Zarr.storefromstring(::Type{<: ReferenceStore}, url, _) end # One could add more corrections here... - return rs, "" # ReferenceStore never has a relative path + return (rs, "") # ReferenceStore never has a relative path end function Zarr.subdirs(store::ReferenceStore, key)