RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
290 stars 46 forks source link

how to load DatArchive in writable state ? #49

Closed k2s closed 4 years ago

k2s commented 4 years ago
const archive = await DatArchive.load(datURL, {
        secretKey,
        persist: false
})
console.log((await archive.readdir('/')).length)
await archive.writeFile('/index.html', '<h1>Hello World!</h1>')

is this bug or how should I provide secretKey to be able to write to the repository ?

RangerMauve commented 4 years ago

Hey! I think you can use the isOwner flag in the data returned by archive.getInfo

k2s commented 4 years ago

Thank you for answer. I don't need to read information, but to set the archive to writable mode.

I forgot to mention that I use it in NodeJS.

RangerMauve commented 4 years ago

In node.js if you created the archive with DatArchive it should be loading the secret key automatically. Otherwise you need to pass in the secret key each time to make it writable.

k2s commented 4 years ago

I have created the dat archive with command line tool dat on different PC. dat sync is running there. Now I want to connect to this dat repository. which works fine until I provide secretKey.

The value I set to secretKey is string output from command dat keys export. With this key provided the DatArchive stops to even to list the content of the archive which works without the secretKey option.

RangerMauve commented 4 years ago

Dat breaks if you try to set the secret key on more than one device at a time. If you want to update an archive from more than one machine, I suggest looking into Kappa-Drive or the mounts feature in Hyperdrive-daemon