Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
fix: protect open and close
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Apr 23, 2020
1 parent 1fef7be commit 0695ad6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class IdbDatastore {
}

async open () {
if (this.store !== null) {
return
}

const location = this.location
try {
this.store = await openDB(this.location, this.version, {
Expand Down Expand Up @@ -189,7 +193,8 @@ class IdbDatastore {
if (this.store === null) {
throw new Error('Datastore needs to be opened.')
}
return this.store.close()
this.store.close()
this.store = null
}

destroy () {
Expand Down

0 comments on commit 0695ad6

Please sign in to comment.