ipfs-webui icon indicating copy to clipboard operation
ipfs-webui copied to clipboard

Switch text preview to range reads

Open lidel opened this issue 5 years ago • 1 comments

Alex noted how partial reads done during preview of text files may lead to leaking resources https://github.com/ipfs-shipyard/ipfs-webui/pull/1646#issuecomment-699043284

The whole point here is that we want to avoid unnecessary reads because text files such as logs can be pretty big. Draining the iterator until completion when a text file is tens/hundreds of megabytes may not be the best approach to ensure resource cleanup happens.

Perhaps could leverage the fact that ipfs.files.read|cat support range requests via offset and length parameters?

The idea is that if the preview ask for specific byte range (256KB block), it no longer needs low level handling of iterator. Something like await concat(await read({ offset: n, length: 262144 })) will read 256K block and without leaking any resources.

lidel avatar Sep 28 '20 11:09 lidel

This issue needs a clear solution to implement before it's actionable.

SgtPooki avatar Dec 02 '22 21:12 SgtPooki