wnfs-wg / rs-wnfs

Rust implementation of the WebNative FileSystem (WNFS) specification
https://github.com/wnfs-wg
Apache License 2.0
147 stars 24 forks source link

getNode fails when multiple segments of the path do not exist #222

Closed icidasset closed 1 year ago

icidasset commented 1 year ago

Calling getNode([ "top-dir", "nested-dir", "file" ]) will result in an error instead of returning null. Where "top-dir" exists, but "nested-dir" and "file" do not.

Given error:

Error: Cannot get node: Invalid WNFS path
appcypher commented 1 year ago

How do you suggest we go about it? You could use a workaround by handling the error or we can introduce a variant of getNode that returns null with invalid paths.

matheus23 commented 1 year ago

Since get_node already returns a Result<Option<...>>, and that's Ok(None) if the last part of the path is missing, it should simply also return Ok(None) when any other path segment is missing.