RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
36 stars 12 forks source link

Delete hyperdrive #77

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

Perhaps we could use a POST request to delete a hyperdrive, like:

POST hyper://localhost/?delete=true&key=NAME

RangerMauve commented 1 year ago

That's a great idea. I think my only adjustment would be to use DELETE hyper://localhost?key=NAME.

Sadly the new version of hypercore/hyperdrive doesn't have a .destroyData() method anymore. https://github.com/holepunchto/hypercore/pull/255

I'll need to dig into the source code to see how to interface with the current storage module to make this happen.

RangerMauve commented 1 year ago

Yeah I think I'll need to submit some PRs for this to hypercore to start.

josephmturner commented 1 year ago

That's a great idea. I think my only adjustment would be to use DELETE hyper://localhost?key=NAME.

Sounds good to me!

Sadly the new version of hypercore/hyperdrive doesn't have a .destroyData() method anymore. holepunchto/hypercore#255

I'll need to dig into the source code to see how to interface with the current storage module to make this happen.

Thank you!

josephmturner commented 1 year ago

DELETE hyper://localhost?key=NAME

We should also provide an API for deleting writable hyperdrives by public key in case the key name is not known.

RangerMauve commented 1 year ago

We should also provide an API for deleting writable hyperdrives by public key in case the key name is not known.

could you elaborate on this use case? in general if an application is creating and destroying drives it should be tracking the names of the drives which it is creating and destroying

josephmturner commented 1 year ago

In hyperdrive.el, we do track names of drives being created or destroyed. I thought it would make sense for hyper-gateway to be the source of truth for writable drive names (while hyperdrive.el would just keep a cache), but from your comment here, I understand that's not intended.

DELETE hyper://localhost?key=NAME sounds like a good API to me!

josephmturner commented 1 year ago

Yeah I think I'll need to submit some PRs for this to hypercore to start.

Is this still the case? I see that the Hyperdrive API now includes drive.purge().

RangerMauve commented 1 year ago

Oh perfect! drive.purge is exactly what I needed.

josephmturner commented 1 year ago

Looks like this is done! Thank you!!