dat-ecosystem-archive / datBase

Open data sharing powered by Dat [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]
http://datbase.org
244 stars 32 forks source link

file preview with sparse content #441

Closed joehand closed 7 years ago

joehand commented 7 years ago

Still very much WIP. A few underlying deps need updates too.

Not sure if the page files will fill with empty buffers or be sparse. We can switch to memory too but need to think about how to make sure that doesn't grow too large. Is there a LRU cache + random-access-memory thing floating around anywhere?

We dont need to use hyperdrive-http but I added those methods this morning and wanted to see if it worked =).

Uses branches of:

okdistribute commented 7 years ago

Great work, let's see if it works after the hypercore fix lands!

okdistribute commented 7 years ago

Previewing only the dat.json file in a 4MB dat creates the page file at the max size (wrong) yet downloads only the dat.json file (correctly sparse).

karissa ~/node_modules/datproject.org
$ du -h archiver/
2.4M    archiver//data/f0/3cf5bca03120269ba7858e805cf32f102c234e703aa073b44aa207639f3bdf.data
2.4M    archiver//data/f0
4.0K    archiver//data/f7/02cd8e76187d355a7a806dc386d2532789b098b104bea73480e94f220714cb.data
4.0K    archiver//data/f7
2.5M    archiver//data
 36K    archiver//db
2.5M    archiver/

karissa ~/node_modules/datproject.org
$ tail archiver/data/f0/3cf5bca03120269ba7858e805cf32f102c234e703aa073b44aa207639f3bdf.data/0.page
{"title":"Powerpoint Karaoke","url":"dat://4c6322037b77afcf13fd1aa0467b39b1eeedaf12a6dc7a6291d466863890b2d9","name":"powerpoint-karaoke","description":"A slide deck that can be used for Power Point Karaoke, also known as BattleDecks"}
okdistribute commented 7 years ago

OK looks like the sparse mode is working now! Hooray!

I added capability to preview files, but there is some wonkyiness with rendering iframes (pdfs, maps, text files). @yoshuawuyts says that caching using el.isSameNode + onload/onunload could fix this.

joehand commented 7 years ago

Nice work hooking up the file previews! They look good. I released the updated versions of hypercore-archiver + hyperdrive-http, so should be all ready there!