holepunchto / hyperdrive-next

Hyperdrive is a secure, real-time distributed file system
https://docs.holepunch.to
Apache License 2.0
45 stars 9 forks source link

Pass options of entry() and get() to Hyperblobs #28

Closed LuKks closed 1 year ago

LuKks commented 1 year ago

Depends on https://github.com/holepunchto/hyperblobs/pull/12 and https://github.com/holepunchto/hypercore/pull/359

gmaclennan commented 1 year ago

This will be very welcome.

The behaviour of drive.get(path) though might need some more explanation. Currently the docs say:

If no blob exists at path, returns null.

However as I understand from testing, there are two other scenarios:

  1. If the index (hyperbee) has not downloaded yet, returns null
  2. If the blobs core (hyperblobs) has not downloaded yet, throw Error 'Block not available'

I'm not sure what the best behaviour is, e.g. when should it throw and when should it return null? Currently throwing because one core has not downloaded, but returning null for the other, does seem a bit confusing.

gmaclennan commented 1 year ago

Should also pass options to the hyperbee, via https://github.com/holepunchto/hyperdrive-next/blob/master/index.js#L182, since otherwise drive.get() can still hang if the hyperbee has not downloaded yet (just discovered this after some extensive debugging!)

LuKks commented 1 year ago

Tests are not passing as I said on the PR description, it depends on the other one first.

LuKks commented 1 year ago

And it also depends on: https://github.com/holepunchto/hypercore/pull/359

LuKks commented 1 year ago

@mafintosh Ready!

LuKks commented 1 year ago

@gmaclennan Feedback highly appreciated! If you would like to confirm the behaviour about null vs Block not available, currently it mostly return null where it makes sense, let me know!

LuKks commented 1 year ago

Follow: https://github.com/holepunchto/hyperdrive/pull/348