restore: Auto-cleanup when an IndexedDBStore is created.

This commit is contained in:
Renée Kooi 2017-09-28 12:32:26 +02:00
parent a542fdf42d
commit 2f14aa8a6e
No known key found for this signature in database
GPG key ID: 30516CF2A8E63718

View file

@ -60,6 +60,7 @@ function waitForRequest (request) {
})
}
let cleanedUp = false
class IndexedDBStore {
constructor (core, opts) {
this.opts = Object.assign({
@ -70,7 +71,18 @@ class IndexedDBStore {
}, opts)
this.name = this.opts.storeName
this.ready = connect(this.opts.dbName)
const createConnection = () => {
return connect(this.opts.dbName)
}
if (!cleanedUp) {
cleanedUp = true
this.ready = IndexedDBStore.cleanup()
.then(createConnection, createConnection)
} else {
this.ready = createConnection
}
}
key (fileID) {