RangerMauve / dat-archive-web

DatArchive implementation for browsers that uses dat-gateway
MIT License
30 stars 4 forks source link

How to write to an Archive you've created and then opened? #2

Closed chrisekelley closed 6 years ago

chrisekelley commented 6 years ago

I made a simple example that tests creating a new Archive, writes to it, then opens it with DatArchive(url), and tries to write to it again. I get the following error:

dat-archive-web.js:2501 Uncaught (in promise) ArchiveNotWritableError: Cannot write to this archive ; Not the owner
    at assertWritePermission (http://127.0.0.1:8080/assets/dat-archive-web.js:322:11)
    at timer (http://127.0.0.1:8080/assets/dat-archive-web.js:193:13)

If this because the archive does not have access to the private keys that were generated when it was created? I see that hyperdrive has a 'writable' property in the metadata that must be set. Or is this an operation that needs to happen on the filesystem/node side inside dat-gateway?

RangerMauve commented 6 years ago

I think the problem is that you're using the default storage which is random-access-memory which means each time you create an archive it's loading all its data for the first time. Instead you should use random-access-idb in the browser. You'll need to create a custom Manager that does this. Check out my demo code for how that works.

chrisekelley commented 6 years ago

Thanks a lot - your demo code was very helpful; I got it working and updated my simple example.