RangerMauve / hypercore-fetch

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

Feature request: directory and file stat #31

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

Is it possible to get information about a Hyperdrive path (to a file or a directory) without downloading its contents? I am interested in ctime, mtime, x-blocks, x-blocks-downloaded. This information could be quickly loaded to give the user a more complete view of a directory beyond just the names of its contents.

I this idea makes sense, maybe an interface could look like fetch('hyper://NAME/example/?stat', {method: 'GET'})

RangerMauve commented 1 year ago

It should be possible to do a HEAD request and get all the metadata about a path without actually downloading it.

Is there data that's missing from there?

josephmturner commented 1 year ago

Great! Would you like me to add a section to the README describing that functionality?

RangerMauve commented 1 year ago

Will do!

josephmturner commented 1 year ago

Thank you!

RangerMauve commented 1 year ago

You can get the version for a drive or file in the ETag header. Some files (not all) will also have a Last-Modified header based on the mtime of the file.

Unless there are other fields that are needed this might be enough?

josephmturner commented 1 year ago

It looks like one way to set metadata.mtime when updating a file with a PUT request to hypercore-fetch is to use a FormData body. Is it possible to set metadata.mtime when updating a file with a PUT request without using a FormData body?

RangerMauve commented 1 year ago

It should be getting set in both situations. If it isn't it's a bug. I'll fix it.

RangerMauve commented 1 year ago

Fixed! Gonna push to hyper-gateway soon