I had an idea last night, we could avoid all the race conditions with a
createDelendentDB method, which for browser dbs just registers a new db
that will be destroyed along with the main one,  but for leveldb would
create the dependent db as a Sublevel of the original leveldb.
On Apr 1, 2014 9:09 PM, "Nolan Lawson" <notifications@github.com> wrote:

> In lib/adapters/leveldb.js:
>
> >  }
> >
> >  LevelPouch.valid = function () {
> >    return (process && !process.browser) || indexDB.valid();
> >  };
> >
> > -// close and delete open leveldb stores
> > -LevelPouch.destroy = utils.toPromise(function (name, opts, callback) {
> > -  opts = utils.extend(true, {}, opts);
> > -  if (process.browser) {
> > -    leveldown = opts.db || leveldown;
> > -  }
> > -  if (dbStore[name]) {
> > -    dbStore[name].close(function () {
> > -      delete dbStore[name];
>
> sweet, we're back on track. now I think I just need to make db.destroy
> sequential as well as PouchDB.destroy.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/daleharvey/pouchdb/pull/1729/files#r11189500>
> .
>