ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.16k stars 3.01k forks source link

dir-index-html: add indicator if CID is cached in local datastore #8817

Open kallisti5 opened 2 years ago

kallisti5 commented 2 years ago

Is your feature request related to a problem? Please describe.

As a user of IPFS, it's difficult to visualize if files are cached on the gateway you're connected to vs if the files need to be retrieved from the network.

Describe the solution you'd like An indicator to show if a CID is cached on the current gateway.

Example (horrible) mock up:

pin

The first three entries are cached on the gateway, the final one would require pulling from other IPFS nodes. Three indicators may be needed:

lidel commented 2 years ago

This is a sensible request.

kallisti5 commented 2 years ago

seems fair. It would also help with the "pinned content visibility" issues found in other issues. It's a bit spread out, but would be a workaround for those.

Also, yeah.. it does sound potentially a bit expensive... so some care would be needed. If it was too expensive theoretically it could be used as an abuse mechanism (hammering a gateway for the availability of a complex recursive CID)

xrazis commented 2 years ago

If i understand correctly this issue does not belong in this repository, the changes need to happen to:

I would love to take a look at it!

lidel commented 2 years ago

I am moving this issue to go-ipfs repo.

Caveat: generating static HTML is expensive, and we want to cache it for as long as possible, have per-release static Etag for these dir listings, so showing this via rendered HTML is not feasible – these status indicators will get out of sync pretty fast due to older version being read from cache.

If you are interested in moving this forward I'd look at https://github.com/ipfs/go-ipfs/issues/8783 This JS check will remove the need for re-generating entire HTML all the time.

If we have it, then static HTML page for dir listing could do JS fetch HEAD request for the each dir child in the viewport by sending request for it (e.g. with Accept: application/vnd.ipfs.cache.local content type). This will work nicely with big directories – we should only fetch the state of visible items.

xrazis commented 2 years ago

@lidel i have a couple of questions before i open a PR. You can see my changes here.

image

lidel commented 2 years ago

@xrazis thank you for poking at this! Feel free to open a PR, we can continue there, but for now quick feedback here: