Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find a way to catch Error: Another hypercore is stored here error #164

Open
aral opened this issue Feb 16, 2019 · 6 comments
Open

Comments

@aral
Copy link
Contributor

aral commented Feb 16, 2019

When creating a new database, if you erroneously try to create a new database over an existing one, you get Error: Another hypercore is stored here. However, I can find no way of catching this error so that I can handle it gracefully when using hyperdb.

@m-onz
Copy link

m-onz commented Feb 16, 2019 via email

@aral
Copy link
Contributor Author

aral commented Feb 16, 2019

@m-onz Sorry, I should’ve been more precise: this is with random-access-idb in the browser and, afaics, there doesn’t seem to be a reliable way to see if an IndexDB database exists or not (!!!)

@m-onz
Copy link

m-onz commented Feb 17, 2019 via email

@aral
Copy link
Contributor Author

aral commented Feb 17, 2019

Regarding my previous point: https://stackoverflow.com/a/23767548

@joehand
Copy link

joehand commented Feb 17, 2019

I was running into this too and decided to use the discovery key so you can store multiple dats:

var crypto = require('hypercore-crypto')
var db = require('random-access-idb')

var key = 'dat://somedatkey'

var discoveryKey = crypto.discoveryKey(key)
var archive = hyperdrive(db(discoveryKey.toString('hex')), key)

@m-onz
Copy link

m-onz commented Feb 17, 2019

Also, you could store your DB name in local storage or as a cookie.

Bit crude but its a work around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants